Skip to content

Commit

Permalink
Make sure to filter out None and Uninferable when gathering exceptions
Browse files Browse the repository at this point in the history
Close #2434
  • Loading branch information
PCManticore committed Aug 23, 2018
1 parent 10d688e commit 064f378
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pylint/checkers/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def gather_exceptions_from_handler(handler):
exceptions = {exception
for exception in exceptions_in_handler.elts
if isinstance(exception, astroid.Name)}
else:
elif exceptions_in_handler:
exceptions = [exceptions_in_handler]
return exceptions

Expand Down
10 changes: 9 additions & 1 deletion pylint/test/functional/try_except_raise.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pylint:disable=missing-docstring, unreachable, bad-except-order, bare-except, unnecessary-pass

# pylint: disable=undefined-variable
try:
int("9a")
except: # [try-except-raise]
Expand Down Expand Up @@ -95,3 +95,11 @@ def ddd():
raise
except (OverflowError, ZeroDivisionError):
print("a failure")


try:
pass
except invalid_name: # [try-except-raise]
raise
except TypeError:
pass
1 change: 1 addition & 0 deletions pylint/test/functional/try_except_raise.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ try-except-raise:53:ddd:The except handler raises immediately
try-except-raise:67::The except handler raises immediately
try-except-raise:72::The except handler raises immediately
try-except-raise:94::The except handler raises immediately
try-except-raise:102::The except handler raises immediately

0 comments on commit 064f378

Please sign in to comment.