[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

Lysandros Nikolaou report at bugs.python.org
Thu May 7 20:56:28 EDT 2020


Lysandros Nikolaou <lisandrosnik at gmail.com> added the comment:

> Hm, but there the old parser seems at fault: it points to the last space rather than beyond it?

Both parsers seem to have the same behaviour, when parsing files. I just found out that even the new parser points to the `|` if there is not trailing whitespace:

╰─ cat -e t.py
x = 1 | 2 |$
╰─ ./python.exe t.py
  File "/Users/lysnikolaou/Repositories/cpython/t.py", line 1
    x = 1 | 2 |
              ^
SyntaxError: invalid syntax
╰─ ./python.exe -X oldparser t.py
  File "/Users/lysnikolaou/Repositories/cpython/t.py", line 1
    x = 1 | 2 |
              ^
SyntaxError: invalid syntax

I'll investigate more tomorrow.

----------

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


More information about the Python-bugs-list mailing list