diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2018-05-23 18:42:18 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-05-23 18:42:25 +0200 |
commit | 37e6384b5f451a737794e41e11a11d561dfc83aa (patch) | |
tree | db617b62c29d1caab14c5a450add5b47a2d40b94 | |
parent | 6edf3af2963f8b797ed5880b217e1d517708c4b3 (diff) | |
download | pylint-git-37e6384b5f451a737794e41e11a11d561dfc83aa.tar.gz |
Don't include excepthandlers that don't have a name when looking for exception-escape
-rw-r--r-- | pylint/checkers/python3.py | 3 | ||||
-rw-r--r-- | pylint/test/unittest_checker_python3.py | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/pylint/checkers/python3.py b/pylint/checkers/python3.py index da7f58eb6..d8215f1f3 100644 --- a/pylint/checkers/python3.py +++ b/pylint/checkers/python3.py @@ -906,6 +906,9 @@ class Python3Checker(checkers.BaseChecker): self.add_message('unpacking-in-except', node=node) return + if not node.name: + return + # Find any names scope = node.parent.scope() scope_names = scope.nodes_of_class( diff --git a/pylint/test/unittest_checker_python3.py b/pylint/test/unittest_checker_python3.py index e61f9cd25..7d8604651 100644 --- a/pylint/test/unittest_checker_python3.py +++ b/pylint/test/unittest_checker_python3.py @@ -757,12 +757,17 @@ class TestPython3Checker(testutils.CheckerTestCase): except (ValueError, TypeError) as exc: exc = 2 exc #@ + try: + 2/0 + except (ValueError, TypeError): #@ + exc = 2 ''') message = testutils.Message('exception-escape', node=module.body[1].value) with self.assertAddsMessages(message): self.checker.visit_excepthandler(module.body[0].handlers[0]) with self.assertNoMessages(): self.checker.visit_excepthandler(module.body[2].handlers[0]) + self.checker.visit_excepthandler(module.body[4].handlers[0]) def test_bad_sys_attribute(self): node = astroid.extract_node(''' |