This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author samuelcolvin
Recipients samuelcolvin
Date 2017-08-20.19:03:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1503255834.0.0.745479367375.issue31241@psf.upfronthosting.co.za>
In-reply-to
Content
With Python 3.5 and 3.6 list comprehensions, generators and tuples have the col_offset for their ast nodes off by 1:

```
import ast
ast.parse('{a for a in range(3)}').body[0].value.col_offset
>> 0  # set comprehension correct

ast.parse('{a: 1 for a in range(3)}').body[0].value.col_offset
>> 0  # dict comprehension correct

ast.parse('[a for a in range(3)]').body[0].value.col_offset
>> 1  # list comprehension wrong!

ast.parse('(a for a in range(3))').body[0].value.col_offset
>> 1  # generator comprehension wrong!

ast.parse('[1, 2, 3]').body[0].value.col_offset
>> 0  # list correct

ast.parse('{1, 2, 3}').body[0].value.col_offset
>> 0  # set correct

ast.parse('{1: 1, 2: 2, 3: 3}').body[0].value.col_offset
>> 0  # dict correct

ast.parse('(1, 2, 3)').body[0].value.col_offset
>> 1  # tuple wrong!
```

I haven't tried 3.4, the issue could be there too.

There are some other related issues #16806 and #21295 but they don't seem quite the same.
History
Date User Action Args
2017-08-20 19:03:54samuelcolvinsetrecipients: + samuelcolvin
2017-08-20 19:03:54samuelcolvinsetmessageid: <1503255834.0.0.745479367375.issue31241@psf.upfronthosting.co.za>
2017-08-20 19:03:53samuelcolvinlinkissue31241 messages
2017-08-20 19:03:53samuelcolvincreate