diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2010-01-25 17:44:50 +0100 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-01-25 17:44:50 +0100 |
commit | 957d645de048283c1d630870cc2182abfd1791b9 (patch) | |
tree | 808aec46f6cd299a2d5135b80d9b1f228f59906a /rebuilder.py | |
parent | 3d6bc2479897ef548ee9fb69a5b94a7125c320b5 (diff) | |
download | astroid-git-957d645de048283c1d630870cc2182abfd1791b9.tar.gz |
fix Discard-Yield combination and some more obvious bugs
--HG--
branch : rebuild
Diffstat (limited to 'rebuilder.py')
-rw-r--r-- | rebuilder.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/rebuilder.py b/rebuilder.py index b44342a3..a8cd5599 100644 --- a/rebuilder.py +++ b/rebuilder.py @@ -63,6 +63,7 @@ class RebuildVisitor(ASTVisitor): # replace set_infos or simplify some other cases ? cls_name = node.__class__.__name__ _method_suffix = REDIRECT.get(cls_name, cls_name).lower() + _visit = getattr(self, "visit_%s" % _method_suffix ) try: newnode = _visit(node) @@ -86,14 +87,23 @@ class RebuildVisitor(ASTVisitor): child.parent = newnode else: print "newnode %s has None as child" % newnode + # line info setting + # XXX We don't get the same type of node back. Rebuilding inserts nodes + # of different type and returns them... Is this a problem ? if hasattr(oldnode, 'lineno'): newnode.lineno = oldnode.lineno - # newnode.set_line_info(child) + if self.set_line_info: # _ast + newnode.set_line_info(child) + else: # compiler + if hasattr(oldnode, 'fromlineno'): + newnode.fromlineno = oldnode.fromlineno + if hasattr(oldnode, 'tolineno'): + newnode.tolineno = oldnode.tolineno def walk(self, node): """start the walk down the tree and do some work after it""" newnode = self.visit(node, None) - _check_children(newnode) + _check_children(newnode) # FIXME : remove this asap for name, nodes in self._delayed.items(): delay_method = getattr(self, 'delayed_' + name) for node in nodes: @@ -182,7 +192,6 @@ class RebuildVisitor(ASTVisitor): if isinstance(decorator_expr, nodes.Name) and \ decorator_expr.name in ('classmethod', 'staticmethod'): node.parent.type = decorator_expr.name - return newnode def visit_ellipsis(self, node): """visit an Ellipsis node by returning a fresh instance of it""" |