Message300606
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. |
|
Date |
User |
Action |
Args |
2017-08-20 19:03:54 | samuelcolvin | set | recipients:
+ samuelcolvin |
2017-08-20 19:03:54 | samuelcolvin | set | messageid: <1503255834.0.0.745479367375.issue31241@psf.upfronthosting.co.za> |
2017-08-20 19:03:53 | samuelcolvin | link | issue31241 messages |
2017-08-20 19:03:53 | samuelcolvin | create | |
|