[New-bugs-announce] [issue10869] ast.increment_lineno() increments root node twice
David White
report at bugs.python.org
Sun Jan 9 01:13:40 CET 2011
New submission from David White <dappawit at 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 <report at bugs.python.org>
<http://bugs.python.org/issue10869>
_______________________________________
More information about the New-bugs-announce
mailing list