Commits

Tarek Ziadé committed 7e6eaa4

make sure the name of the exception is added in the scope of the exception - fixes #10

Comments (0)

Files changed (2)

flake8/pyflakes.py

     EQ = NOTEQ = LT = LTE = GT = GTE = IS = ISNOT = IN = NOTIN = ignore
 
     # additional node types
-    COMPREHENSION = EXCEPTHANDLER = KEYWORD = handleChildren
+    COMPREHENSION = KEYWORD = handleChildren
+
+    def EXCEPTHANDLER(self, node):
+        self.scope[node.name] = node
 
     def addBinding(self, lineno, value, reportRedef=True):
         '''Called when a binding is altered.
         return 1
 
 
-def check(codeString, filename):
+def check(codeString, filename='(code)'):
     """
     Check the Python source given by C{codeString} for flakes.
 

flake8/tests/test_flakes.py

+from unittest import TestCase
+from flake8.pyflakes import check
+
+
+code = """
+try:
+    pass
+except ValueError as err:
+    print(err)
+"""
+
+
+class TestFlake(TestCase):
+
+    def test_exception(self):
+        warnings = check(code)
+        self.assertEqual(warnings, 0)