Armin Ronacher <[EMAIL PROTECTED]> added the comment: This is actually not a bug. copy_location does not work recursively. For this example it's more useful to use the "fix_missing_locations" function which traverses the tree and copies the locations from the parent node to the child nodes:
import ast a = ast.parse('foo', mode='eval') x = compile(a, '<unknown>', mode='eval') class RewriteName(ast.NodeTransformer): def visit_Name(self, node): return ast.Subscript( value=ast.Name(id='data', ctx=ast.Load()), slice=ast.Index(value=ast.Str(s=node.id)), ctx=node.ctx ) a2 = ast.fix_missing_locations(RewriteName().visit(a)) _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3530> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com