diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pylint/checkers/exceptions.py | 2 | ||||
-rw-r--r-- | pylint/test/functional/broad_except.py | 6 | ||||
-rw-r--r-- | pylint/test/functional/broad_except.txt | 3 |
4 files changed, 13 insertions, 2 deletions
@@ -7,6 +7,10 @@ What's New in Pylint 2.3.0? Release date: TBA +* Allow ``BaseException`` for emitting ``broad-except``, just like ``Exception``. + + Close #2741 + * Fixed a crash that occurred for ``bad-str-strip-call`` when ``strip()`` received ``None`` Close #2743 diff --git a/pylint/checkers/exceptions.py b/pylint/checkers/exceptions.py index 80ea98ae2..c43af53af 100644 --- a/pylint/checkers/exceptions.py +++ b/pylint/checkers/exceptions.py @@ -70,7 +70,7 @@ def _is_raising(body: typing.List) -> bool: PY3K = sys.version_info >= (3, 0) -OVERGENERAL_EXCEPTIONS = ("Exception",) +OVERGENERAL_EXCEPTIONS = ("BaseException", "Exception") BUILTINS_NAME = builtins.__name__ MSGS = { diff --git a/pylint/test/functional/broad_except.py b/pylint/test/functional/broad_except.py index f71431e0b..24c839951 100644 --- a/pylint/test/functional/broad_except.py +++ b/pylint/test/functional/broad_except.py @@ -6,3 +6,9 @@ try: __revision__ += 1 except Exception: # [broad-except] print('error') + + +try: + __revision__ += 1 +except BaseException: # [broad-except] + print('error') diff --git a/pylint/test/functional/broad_except.txt b/pylint/test/functional/broad_except.txt index bb44550c0..5a46b03be 100644 --- a/pylint/test/functional/broad_except.txt +++ b/pylint/test/functional/broad_except.txt @@ -1 +1,2 @@ -broad-except:7::Catching too general exception Exception
\ No newline at end of file +broad-except:7::Catching too general exception Exception +broad-except:13::Catching too general exception BaseException |