New submission from David White <dappa...@gmail.com>: When using ast.increment_lineno(), it visits the root node twice. Therefore if the root node contains the lineno attribute, it is incremented twice. (Often, the root node will not have a lineno attribute, so there is no effect. This is why the current test case passes.)
I believe that part of the problem is that the docs for ast.walk(), which ast.increment_lineno() calls, state that it visits all child nodes of the given node. It does not state that it also visits the given node itself. I use 2.7, but I noticed the same issue is present in 3.1 and the py3k branch. I have written a patch that fixes both of these issues, ast.increment_lineno and the ast.walk docs, and adds a new test case to the test suite. I will be posting it after I submit the issue (so I have the issue number). ---------- components: Library (Lib) messages: 125813 nosy: dpwhite2 priority: normal severity: normal status: open title: ast.increment_lineno() increments root node twice type: behavior versions: Python 2.7, Python 3.1, Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10869> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com