[issue31241] ast col_offset wrong for list comprehensions, generators and tuples

Serhiy Storchaka report at bugs.python.org
Wed Nov 21 07:20:29 EST 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

For list comprehensions and generator expressions this is definitely a bug. But tuples syntax technically does not include surrounded parentheses.

There is also a problem with generator expression passes as a single argument. Generator expression parentheses can be collapsed with function call parentheses: f(a for a in b).

PR 10633 makes the following changes:

* Fixes position for list comprehensions and generator expressions.

* If generator expression parentheses are be collapsed with function call parentheses, the position of the AST node for the generator expression points to the left parenthesis.

* For tuples surrounded with parentheses, the position of the AST node points to the left brace. For tuples without parentheses, it points to the position of the first tuple item.

I am not sure whether these changes should be backported to maintained versions.

----------
nosy: +benjamin.peterson, brett.cannon, yselivanov

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31241>
_______________________________________


More information about the Python-bugs-list mailing list