summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2019-02-13 10:12:01 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2019-02-13 10:12:01 +0100
commit612b87a3b3eaa6e862198c99d120e492cbfa19d9 (patch)
tree4e931d7c2817eb8438d2638fe04709320a28c22e
parentc95f911a915ab88573bcc65217eed7f488281df6 (diff)
downloadpylint-git-612b87a3b3eaa6e862198c99d120e492cbfa19d9.tar.gz
Allow ``BaseException`` for emitting ``broad-except``, just like ``Exception``.
Close #2741
-rw-r--r--ChangeLog4
-rw-r--r--pylint/checkers/exceptions.py2
-rw-r--r--pylint/test/functional/broad_except.py6
-rw-r--r--pylint/test/functional/broad_except.txt3
4 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index e4f6d2575..121d228cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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