[New-bugs-announce] [issue25677] Syntax error caret confused by indentation

Michael Layzell report at bugs.python.org
Fri Nov 20 00:50:56 EST 2015


New submission from Michael Layzell:

It appears that syntax errors generated by checking the AST will get confused by indentation and place the caret incorrectly.

With no indentation:
===
1 + 1 = 2
===
  File "/Users/mlayzell/test.py", line 1
    1 + 1 = 2
    ^
SyntaxError: can't assign to operator
===

With 4 spaces of indentation:
===
if True:
    1 + 1 = 2
===
  File "/Users/mlayzell/test.py", line 2
    1 + 1 = 2
       ^
SyntaxError: can't assign to operator
===

As you can see, the caret appears to be placed randomly in the middle of the second statement, apparently offset (probably by the 4 space indentation).

The above examples were run with Python3.5 on Mac OS X 10.10.4, though my somewhat-recent trunk clone exhibits the same problems.

----------
components: Interpreter Core
messages: 254951
nosy: Michael Layzell
priority: normal
severity: normal
status: open
title: Syntax error caret confused by indentation
type: behavior
versions: Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25677>
_______________________________________


More information about the New-bugs-announce mailing list