Added code to handle unknown node types to the pyflakes checker.

Wed, 03 Oct 2012 12:18:51 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 03 Oct 2012 12:18:51 +0200
changeset 2088
73a2ca4ac409
parent 2087
795992a5c561
child 2089
d23ab571d2b9

Added code to handle unknown node types to the pyflakes checker.

Utilities/py3flakes/checker.py file | annotate | diff | comparison | revisions
UtilitiesPython2/py2flakes/checker.py file | annotate | diff | comparison | revisions
diff -r 795992a5c561 -r 73a2ca4ac409 Utilities/py3flakes/checker.py
--- a/Utilities/py3flakes/checker.py	Tue Oct 02 19:53:31 2012 +0200
+++ b/Utilities/py3flakes/checker.py	Wed Oct 03 12:18:51 2012 +0200
@@ -283,6 +283,8 @@
             try:
                 handler = getattr(self, nodeType)
                 handler(node)
+            except AttributeError:
+                print(nodeType, "not supported yet. Please report this.")
             finally:
                 self.nodeDepth -= 1
             if self.traceTree:
diff -r 795992a5c561 -r 73a2ca4ac409 UtilitiesPython2/py2flakes/checker.py
--- a/UtilitiesPython2/py2flakes/checker.py	Tue Oct 02 19:53:31 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