[Python-checkins] Fix syntax error in an example in the ast documentation and sync docstrings (GH-18946)

Miss Islington (bot) webhook-mailer at python.org
Wed Mar 11 21:05:52 EDT 2020


https://github.com/python/cpython/commit/500999fbdfdea8c86ed84221b5cad551daa8cf9f
commit: 500999fbdfdea8c86ed84221b5cad551daa8cf9f
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-03-11T18:05:45-07:00
summary:

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 <Pablogsal at gmail.com>

files:
M Doc/library/ast.rst
M Lib/ast.py

diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
index 6d6ae6de78a01..1dddad8275ac9 100644
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -244,7 +244,7 @@ and classes for traversing abstract syntax trees:
                   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`
diff --git a/Lib/ast.py b/Lib/ast.py
index 1bc6b38da8d5a..818d5638232d3 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -298,11 +298,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`



More information about the Python-checkins mailing list