[issue3530] ast.NodeTransformer doc bug

2020-01-12 Thread miss-islington


miss-islington  added the comment:


New changeset e222b4c69f99953a14ded52497a9909e34fc3893 by Miss Islington (bot) 
in branch '3.7':
bpo-3530: Add advice on when to correctly use fix_missing_locations in the AST 
docs (GH-17172)
https://github.com/python/cpython/commit/e222b4c69f99953a14ded52497a9909e34fc3893


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3530] ast.NodeTransformer doc bug

2020-01-12 Thread miss-islington


miss-islington  added the comment:


New changeset ef0af30e507a29dae03aae40459b9c44c96f260d by Miss Islington (bot) 
in branch '3.8':
bpo-3530: Add advice on when to correctly use fix_missing_locations in the AST 
docs (GH-17172)
https://github.com/python/cpython/commit/ef0af30e507a29dae03aae40459b9c44c96f260d


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3530] ast.NodeTransformer doc bug

2020-01-12 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3530] ast.NodeTransformer doc bug

2020-01-12 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:


New changeset 6680f4a9f5d15ab82b2ab6266c6f917cb78c919a by Pablo Galindo 
(Batuhan Taşkaya) in branch 'master':
bpo-3530: Add advice on when to correctly use fix_missing_locations in the AST 
docs (GH-17172)
https://github.com/python/cpython/commit/6680f4a9f5d15ab82b2ab6266c6f917cb78c919a


--
nosy: +pablogsal

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3530] ast.NodeTransformer doc bug

2020-01-12 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17379
pull_request: https://github.com/python/cpython/pull/17972

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3530] ast.NodeTransformer doc bug

2020-01-12 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17380
pull_request: https://github.com/python/cpython/pull/17973

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3530] ast.NodeTransformer doc bug

2019-11-16 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
versions: +Python 3.7, Python 3.8, Python 3.9 -Python 3.4, Python 3.5, Python 
3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3530] ast.NodeTransformer doc bug

2019-11-16 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I re-verified the problem, its presence in the doc, and the fix with 3.9.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3530] ast.NodeTransformer doc bug

2019-11-15 Thread Batuhan


Change by Batuhan :


--
keywords: +patch
pull_requests: +16681
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/17172

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3530] ast.NodeTransformer doc bug

2015-06-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I am reopening this as a doc bug because RewriteName is a copy (with 'ast.' 
prefixes added) of a buggy example in the doc. The bug is that the new .value 
Name and Str attributes do not get the required 'lineno' and 'col_offset' 
attributes.  As Armin said, copy_location is not recursive and does not fix 
children of the node it fixes.  Also, the recursive .visit method does not 
recurse into children of replacement nodes (and if it did, the new Str node 
would still not be fixed).

The fix could be to reuse the Name node and add another copy_location call: the 
following works.

def visit_Name(self, node):
return ast.copy_location(
ast.Subscript(
value=node,
slice=ast.Index(value=ast.copy_location(
ast.Str(s=node.id), node)),
ctx=node.ctx),
node)

but I think this illustrates that comment in the fix_missing_locations() entry 
that locations are tedious to fill in for generated nodes.  So I think the 
doc fix should use Armin's version of RewriteName and say to call 
fix_missing_locations on the result of .visit if new nodes are added.  (I 
checked that his code still works in 3.5).

The entry for NodeTransformer might mention that .visit does not recurse into 
replacement nodes.

The missing lineno error came up in this python-list thread:
https://mail.python.org/pipermail/python-list/2015-June/693316.html

--
assignee:  - docs@python
components: +Documentation
nosy: +benjamin.peterson, docs@python, terry.reedy
resolution: not a bug - 
stage:  - needs patch
status: closed - open
title: ast.NodeTransformer bug - ast.NodeTransformer doc bug
type:  - behavior
versions: +Python 2.7, Python 3.4, Python 3.5, Python 3.6 -Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3530
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com