summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorEmile Anclin <emile.anclin@logilab.fr>2010-02-17 09:38:49 +0100
committerEmile Anclin <emile.anclin@logilab.fr>2010-02-17 09:38:49 +0100
commit4693a2b1c7d948e2036ce8d324d5f08fd7a16efe (patch)
treeb77dc72b5fd98d125927631438b4a601189f2d03 /utils.py
parentfc5c916b68953364f03df49918c1a4c6218f4601 (diff)
downloadastroid-git-4693a2b1c7d948e2036ce8d324d5f08fd7a16efe.tar.gz
move _check_children to utils; don't call it
--HG-- branch : rebuild
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/utils.py b/utils.py
index e18f9847..03581d44 100644
--- a/utils.py
+++ b/utils.py
@@ -22,7 +22,7 @@ extract information from it
__docformat__ = "restructuredtext en"
-from logilab.astng._exceptions import IgnoreChild
+from logilab.astng._exceptions import IgnoreChild, ASTNGBuildingException
class ASTVisitor(object):
@@ -338,5 +338,29 @@ class LocalsVisitor(ASTWalker):
if methods[1] is not None:
return methods[1](node)
+
+def _check_children(node):
+ """a helper function to check children - parent relations"""
+ for child in node.get_children():
+ ok = False
+ if child is None:
+ print "Hm, child of %s is None" % node
+ continue
+ if not hasattr(child, 'parent'):
+ print " ERROR: %s has child %s %x with no parent" % (node, child, id(child))
+ elif not child.parent:
+ print " ERROR: %s has child %s %x with parent %r" % (node, child, id(child), child.parent)
+ elif child.parent is not node:
+ print " ERROR: %s %x has child %s %x with wrong parent %s" % (node,
+ id(node), child, id(child), child.parent)
+ else:
+ ok = True
+ if not ok:
+ print "lines;", node.lineno, child.lineno
+ print "of module", node.root(), node.root().name
+ raise ASTNGBuildingException
+ _check_children(child)
+
+
__all__ = ('REDIRECT', 'LocalsVisitor', 'ASTWalker', 'ASTVisitor',)