Commits

Virgil Dupras  committed 29c206a

Fixed a newly introduced false warning with unnamed exception handling.

  • Participants
  • Parent commits af08ba9

Comments (0)

Files changed (3)

File pyflakes/checker.py

     def EXCEPTHANDLER(self, node):
         # in addition to handling children, we must handle the name of the exception, which is not
         # a Name node, but a simple string.
-        self.handleNameStore(node.name, node)
+        if node.name:
+            self.handleNameStore(node.name, node)
         self.handleChildren(node)
         

File pyflakes/test/test_imports.py

         except: fu
         ''')
     
-    def test_exceptionUsedInExcept(self):
-        self.flakes('''
-        try: pass
-        except Exception as e: e
-        ''')
-    
     def test_redefinedByExcept(self):
         self.flakes('''
         import fu

File pyflakes/test/test_other.py

             return bar
         ''')
 
-
-
-class Python25Test(harness.Test):
-    """
-    Tests for checking of syntax only available in Python 2.5 and newer.
-    """
     def test_ifexp(self):
         """
         Test C{foo if bar else baz} statements.
             pass
         ''', m.UndefinedName)
 
-
-
-class Python27Test(harness.Test):
-    """
-    Tests for checking of syntax only available in Python 2.7 and newer.
-    """
     def test_dictComprehension(self):
         """
         Dict comprehensions are properly handled.
         a = {1, 2, 3}
         b = {x for x in range(10)}
         ''')
+
+    def test_exceptionUsedInExcept(self):
+        self.flakes('''
+        try: pass
+        except Exception as e: e
+        ''')
+    
+    def test_exceptWithoutNameInFunction(self):
+        """
+        Don't issue false warning when an unnamed exception is used. Previously, there would be
+        a false warning, but only when the try..except was in a function
+        """
+        self.flakes('''
+        def foo():
+            try: pass
+            except Exception: pass
+        ''')