From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 12 Mar 2020 01:06:53 +0000 (-0700) Subject: Fix syntax error in an example in the ast documentation and sync docstrings (GH-18946) X-Git-Tag: v3.8.3rc1~108 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=99ef1ac9a7793dcdf624d2400e51ed34eb8d0af3;p=thirdparty%2FPython%2Fcpython.git Fix syntax error in an example in the ast documentation and sync docstrings (GH-18946) (cherry picked from commit c00c86b90443dbf3534cc4786a0b42b58db6e8af) Co-authored-by: Pablo Galindo --- diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst index 80afbbce4167..6ca27609e93b 100644 --- a/Doc/library/ast.rst +++ b/Doc/library/ast.rst @@ -308,7 +308,7 @@ and classes for traversing abstract syntax trees: value=Name(id='data', ctx=Load()), slice=Index(value=Constant(value=node.id)), ctx=node.ctx - ), node) + ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth:`generic_visit` diff --git a/Lib/ast.py b/Lib/ast.py index b45f1e47c197..157a8332ebcc 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -408,11 +408,11 @@ class NodeTransformer(NodeVisitor): class RewriteName(NodeTransformer): def visit_Name(self, node): - return copy_location(Subscript( + return Subscript( value=Name(id='data', ctx=Load()), slice=Index(value=Str(s=node.id)), ctx=node.ctx - ), node) + ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth:`generic_visit`