This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PEG Parser: SyntaxError text empty when last line has a LINECONT
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, lys.nikolaou, miss-islington, pablogsal
Priority: normal Keywords: patch

Created on 2020-06-15 13:45 by lys.nikolaou, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 20888 merged lys.nikolaou, 2020-06-15 14:35
PR 20905 merged miss-islington, 2020-06-16 00:27
Messages (6)
msg371544 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2020-06-15 13:45
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
msg371545 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2020-06-15 13:50
Copying and pasting the example messed the formatting up. Here it is again.

[16:49:16] lysnikolaou:cpython git:(master*) $ cat t.py
x = 6\%                                                                                               [16:49:23] lysnikolaou:cpython git:(master*) $ ./python t.py
  File "/home/lysnikolaou/repos/cpython/t.py", line 2
    
    ^
SyntaxError: unexpected EOF while parsing
[16:49:56] lysnikolaou: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
msg371547 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2020-06-15 13:53
I keep doing something wrong. I hope it is clean by now what the difference is.
msg371584 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-06-15 18:47
Yes, it's clear. :-) This is one reason we need to migrate off bpo and onto GitHub.
msg371609 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-06-16 00:27
New changeset 113e2b0a07c72c0d5e3489076afb14f6b3ad1049 by Lysandros Nikolaou in branch 'master':
bpo-40985: Show correct SyntaxError text when last line has a LINECONT (GH-20888)
https://github.com/python/cpython/commit/113e2b0a07c72c0d5e3489076afb14f6b3ad1049
msg371610 - (view) Author: miss-islington (miss-islington) Date: 2020-06-16 00:46
New changeset 097b8b6d52e3d4991c68dce74f182718dc0eab9c by Miss Islington (bot) in branch '3.9':
bpo-40985: Show correct SyntaxError text when last line has a LINECONT (GH-20888)
https://github.com/python/cpython/commit/097b8b6d52e3d4991c68dce74f182718dc0eab9c
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85157
2020-06-16 00:46:51miss-islingtonsetmessages: + msg371610
2020-06-16 00:29:43lys.nikolaousetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-06-16 00:27:56miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request20088
2020-06-16 00:27:41pablogsalsetmessages: + msg371609
2020-06-15 18:47:44gvanrossumsetmessages: + msg371584
2020-06-15 14:35:11lys.nikolaousetkeywords: + patch
stage: patch review
pull_requests: + pull_request20071
2020-06-15 13:53:55lys.nikolaousetmessages: + msg371547
2020-06-15 13:53:32lys.nikolaousetnosy: + gvanrossum, pablogsal
2020-06-15 13:50:22lys.nikolaousetmessages: + msg371545
2020-06-15 13:45:34lys.nikolaoucreate