[New-bugs-announce] [issue40985] PEG Parser: SyntaxError text empty when last line has a LINECONT

Lysandros Nikolaou report at bugs.python.org
Mon Jun 15 09:45:35 EDT 2020


New submission from Lysandros Nikolaou <lisandrosnik at gmail.com>:

While investigating bpo-40958, the following came up:

When a file ends with a line that contains a line continuation character the text of the emitted SyntaxError is empty, contrary to the old parser, where the error text contained the text of the last line. Here is an example:

cpython git:(master)$ cat t.py
x = 6\%                                                                                                                                                            cpython git:(master)$ ./python t.py
  File "/home/lysnikolaou/repos/cpython/t.py", line 2
    
    ^
SyntaxError: unexpected EOF while parsing
cpython git:(master)$ python3.9 -X oldparser t.py
  File "/home/lysnikolaou/repos/cpython/t.py", line 2
    x = 6\
          ^
SyntaxError: unexpected EOF while parsing

----------
components: Interpreter Core
messages: 371544
nosy: lys.nikolaou
priority: normal
severity: normal
status: open
title: PEG Parser: SyntaxError text empty when last line has a LINECONT
type: behavior
versions: Python 3.10, Python 3.9

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


More information about the New-bugs-announce mailing list