[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

Lysandros Nikolaou report at bugs.python.org
Thu May 7 19:53:42 EDT 2020


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

> But if the col_offset points way past the text, what should happen? The clipping there seems reasonable.

Note that if a file is being parsed and not a string the behaviour is this:
╰─ cat -e t.py
x = 1 | 2 |    $
╰─ ./python.exe t.py
  File "/Users/lysnikolaou/repos/cpython/t.py", line 1
    x = 1 | 2 |
                  ^
SyntaxError: invalid syntax
╰─ ./python.exe -X oldparser t.py
  File "/Users/lysnikolaou/repos/cpython/t.py", line 1
    x = 1 | 2 |
                  ^
SyntaxError: invalid syntax

Would we want to also change this? If not, then I guess that we should as closely as possible match this behaviour with strings as well, which means not clipping.

----------

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


More information about the Python-bugs-list mailing list