mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-13 08:04:18 +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):
|
def EXCEPTHANDLER(self, node):
|
||||||
|
|
||||||
if node.name is not None:
|
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():
|
def runException():
|
||||||
for stmt in node.body:
|
for stmt in node.body:
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,25 @@ code2 = """
|
||||||
try:
|
try:
|
||||||
pass
|
pass
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print(err)
|
print("err")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pass
|
pass
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print(err)
|
print("err")
|
||||||
|
"""
|
||||||
|
|
||||||
|
code3 = """
|
||||||
|
try:
|
||||||
|
pass
|
||||||
|
except (ImportError, ValueError):
|
||||||
|
print("err")
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class TestFlake(TestCase):
|
class TestFlake(TestCase):
|
||||||
|
|
||||||
def test_exception(self):
|
def test_exception(self):
|
||||||
for c in (code, code2):
|
for c in (code, code2, code3):
|
||||||
warnings = check(code)
|
warnings = check(code)
|
||||||
self.assertEqual(warnings, 0)
|
self.assertEqual(warnings, 0, code)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue