UtilitiesPython2/py2flakes/checker.py

branch
5_2_x
changeset 2090
a74544498a96
parent 1544
d06ffad32855
child 2302
f29e9405c851
diff -r 5b7dad2b27ec -r a74544498a96 UtilitiesPython2/py2flakes/checker.py
--- a/UtilitiesPython2/py2flakes/checker.py	Mon Oct 01 19:55:49 2012 +0200
+++ b/UtilitiesPython2/py2flakes/checker.py	Wed Oct 03 12:18:51 2012 +0200
@@ -285,21 +285,24 @@
                 isinstance(node.value, _ast.Str))
 
     def handleNode(self, node, parent):
-        node.parent = parent
-        if self.traceTree:
-            print '  ' * self.nodeDepth + node.__class__.__name__
-        self.nodeDepth += 1
-        if self.futuresAllowed and not \
-               (isinstance(node, _ast.ImportFrom) or self.isDocstring(node)):
-            self.futuresAllowed = False
-        nodeType = node.__class__.__name__.upper()
-        try:
-            handler = getattr(self, nodeType)
-            handler(node)
-        finally:
-            self.nodeDepth -= 1
-        if self.traceTree:
-            print '  ' * self.nodeDepth + 'end ' + node.__class__.__name__
+        if node:
+            node.parent = parent
+            if self.traceTree:
+                print '  ' * self.nodeDepth + node.__class__.__name__
+            self.nodeDepth += 1
+            if self.futuresAllowed and not \
+                   (isinstance(node, _ast.ImportFrom) or self.isDocstring(node)):
+                self.futuresAllowed = False
+            nodeType = node.__class__.__name__.upper()
+            try:
+                handler = getattr(self, nodeType)
+                handler(node)
+            except AttributeError:
+                print nodeType, "not supported yet. Please report this."
+            finally:
+                self.nodeDepth -= 1
+            if self.traceTree:
+                print '  ' * self.nodeDepth + 'end ' + node.__class__.__name__
 
     def ignore(self, node):
         pass

eric ide

mercurial