mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-04 12:16:53 +00:00
more weird edge cases py2/3
This commit is contained in:
parent
ef4b069970
commit
fabd0fa801
2 changed files with 16 additions and 5 deletions
|
|
@ -334,7 +334,11 @@ class Checker(object):
|
|||
def EXCEPTHANDLER(self, node):
|
||||
|
||||
if node.name is not None:
|
||||
self.addBinding(node.lineno, Assignment(node.name, node))
|
||||
if isinstance(node.name, str):
|
||||
name = node.name
|
||||
else:
|
||||
name = node.name.id
|
||||
self.addBinding(node.lineno, Assignment(name, node))
|
||||
|
||||
def runException():
|
||||
for stmt in node.body:
|
||||
|
|
|
|||
|
|
@ -13,18 +13,25 @@ code2 = """
|
|||
try:
|
||||
pass
|
||||
except ValueError:
|
||||
print(err)
|
||||
print("err")
|
||||
|
||||
try:
|
||||
pass
|
||||
except ValueError:
|
||||
print(err)
|
||||
print("err")
|
||||
"""
|
||||
|
||||
code3 = """
|
||||
try:
|
||||
pass
|
||||
except (ImportError, ValueError):
|
||||
print("err")
|
||||
"""
|
||||
|
||||
|
||||
class TestFlake(TestCase):
|
||||
|
||||
def test_exception(self):
|
||||
for c in (code, code2):
|
||||
for c in (code, code2, code3):
|
||||
warnings = check(code)
|
||||
self.assertEqual(warnings, 0)
|
||||
self.assertEqual(warnings, 0, code)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue