From b5aea8dffe9dfb71db10d7107d43cb61aee69193 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Wed, 11 Mar 2020 23:57:25 +0000 Subject: [PATCH] Fix syntax error in ast Docs example and sync docstring --- Doc/library/ast.rst | 2 +- Lib/ast.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst index 45f16c17d3d383..fc04114949c0c3 100644 --- a/Doc/library/ast.rst +++ b/Doc/library/ast.rst @@ -1704,7 +1704,7 @@ and classes for traversing abstract syntax trees: value=Name(id='data', ctx=Load()), slice=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 8b88d0fac05ae6..077eb92abb4028 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -443,11 +443,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=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`