summaryrefslogtreecommitdiffstats
path: root/Lib/ast.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-01-09 07:53:14 (GMT)
committerGeorg Brandl <georg@python.org>2011-01-09 07:53:14 (GMT)
commit6adb97939b132f9dcd2b6c440eaae445b20a15e0 (patch)
treec14a4395d76806b422dc446de7c9545be344fe8f /Lib/ast.py
parentcec4b4fa049426c9d93eebb1feb34204487d495e (diff)
downloadcpython-6adb97939b132f9dcd2b6c440eaae445b20a15e0.zip
cpython-6adb97939b132f9dcd2b6c440eaae445b20a15e0.tar.gz
cpython-6adb97939b132f9dcd2b6c440eaae445b20a15e0.tar.bz2
Merged revisions 87876-87877 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r87876 | georg.brandl | 2011-01-09 08:38:51 +0100 (So, 09 Jan 2011) | 1 line #10869: do not visit root node twice in ast.increment_lineno(). ........ r87877 | georg.brandl | 2011-01-09 08:50:48 +0100 (So, 09 Jan 2011) | 1 line Add missing line. ........
Diffstat (limited to 'Lib/ast.py')
-rw-r--r--Lib/ast.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/ast.py b/Lib/ast.py
index d778a85..7f35f18 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -152,8 +152,6 @@ def increment_lineno(node, n=1):
Increment the line number of each node in the tree starting at *node* by *n*.
This is useful to "move code" to a different location in a file.
"""
- if 'lineno' in node._attributes:
- node.lineno = getattr(node, 'lineno', 0) + n
for child in walk(node):
if 'lineno' in child._attributes:
child.lineno = getattr(child, 'lineno', 0) + n
@@ -204,9 +202,9 @@ def get_docstring(node, clean=True):
def walk(node):
"""
- Recursively yield all child nodes of *node*, in no specified order. This is
- useful if you only want to modify nodes in place and don't care about the
- context.
+ Recursively yield all descendant nodes in the tree starting at *node*
+ (including *node* itself), in no specified order. This is useful if you
+ only want to modify nodes in place and don't care about the context.
"""
from collections import deque
todo = deque([node])