[issue10869] ast.increment_lineno() increments root node twice

2011-01-08 Thread David White

New submission from David White :

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 
<http://bugs.python.org/issue10869>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10869] ast.increment_lineno() increments root node twice

2011-01-08 Thread David White

Changes by David White :


--
keywords: +patch
Added file: http://bugs.python.org/file20317/increment_linenos_27.patch

___
Python tracker 
<http://bugs.python.org/issue10869>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10869] ast.increment_lineno() increments root node twice

2011-01-08 Thread David White

Changes by David White :


Added file: http://bugs.python.org/file20318/increment_linenos_31.patch

___
Python tracker 
<http://bugs.python.org/issue10869>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10869] ast.increment_lineno() increments root node twice

2011-01-08 Thread David White

Changes by David White :


--
resolution:  -> fixed
Added file: http://bugs.python.org/file20319/increment_linenos_3k.patch

___
Python tracker 
<http://bugs.python.org/issue10869>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10869] ast.increment_lineno() increments root node twice

2011-01-08 Thread David White

David White  added the comment:

I've uploaded the patches.  Beware, this is my first attempt to contribute.

--

___
Python tracker 
<http://bugs.python.org/issue10869>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com