From 1ad357ba4a6c788b3f1992953013bbc5d51043ee Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Mon, 19 Dec 2022 09:45:39 +1100 Subject: [PATCH] =?UTF-8?q?Specify=20the=20=E2=80=98Exception=E2=80=99=20c?= =?UTF-8?q?atch-all=20exception=20class,=20not=20a=20bare=20=E2=80=98excep?= =?UTF-8?q?t=E2=80=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PEP 8 specifies: * When catching exceptions, mention specific exceptions whenever possible instead of using a bare `except:` clause […] A bare `except:` clause will catch `SystemExit` and `KeyboardInterrupt` exceptions, making it harder to interrupt a program with Control-C, and can disguise other problems. If you want to catch all exceptions that signal program errors, use `except Exception:` (bare except is equivalent to `except BaseException:`). --- auth-mastodon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth-mastodon.py b/auth-mastodon.py index 1e0b377..92d8c4a 100644 --- a/auth-mastodon.py +++ b/auth-mastodon.py @@ -61,7 +61,7 @@ try: ) database.set_session(readonly=True, autocommit=True) logging.debug(database.get_dsn_parameters()) -except: +except Exception: logging.error("Unable to initialize database, check settings!") time.sleep(10) sys.exit(1)