Message325366
Input file with a subtle error: a number where an assignment target is required:
for 1 in []: pass
Run it, it gives a SyntaxError. Note how the caret pointing to the incorrect token is position one to the left of where you'd expect it:
File "s.py", line 1
for 1 in []: pass
^
SyntaxError: can't assign to literal
For every syntax error I've seen that's produced by ast.c this seems to be the case -- the caret is always positioned 1 too far left.
I tried to understand how this is happening but my AST-fu is lacking. It seems this has been happening since ast.c started added column numbers -- in Python 2.7 there's no caret at all, but in 3.4 and later there's a caret and it has the same problem. (Also in 3.3; I don't have 3.2 or older 3.x lying around to test.) |
|
| Date |
User |
Action |
Args |
| 2018-09-14 17:22:22 | gvanrossum | set | recipients:
+ gvanrossum |
| 2018-09-14 17:22:22 | gvanrossum | set | messageid: <1536945742.16.0.956365154283.issue34683@psf.upfronthosting.co.za> |
| 2018-09-14 17:22:22 | gvanrossum | link | issue34683 messages |
| 2018-09-14 17:22:22 | gvanrossum | create | |
|