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

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

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 03 Oct 2012 12:18:51 +0200
branch
5_2_x
changeset 2090
a74544498a96
parent 2086
5b7dad2b27ec
child 2091
cf95a549ec91

Added code to handle unknown node types to the pyflakes checker.
(grafted from 73a2ca4ac409e1de0c42691701a67c54824ceba4)

Utilities/py3flakes/checker.py file | annotate | diff | comparison | revisions
UtilitiesPython2/py2flakes/checker.py file | annotate | diff | comparison | revisions
--- a/Utilities/py3flakes/checker.py	Mon Oct 01 19:55:49 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:
--- 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