Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEG Parser: SyntaxError text empty when last line has a LINECONT #85157

Closed
lysnikolaou opened this issue Jun 15, 2020 · 6 comments
Closed

PEG Parser: SyntaxError text empty when last line has a LINECONT #85157

lysnikolaou opened this issue Jun 15, 2020 · 6 comments
Labels
3.9 only security fixes 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@lysnikolaou
Copy link
Contributor

BPO 40985
Nosy @gvanrossum, @lysnikolaou, @pablogsal, @miss-islington
PRs
  • bpo-40985: Show correct SyntaxError text when last line has a LINECONT #20888
  • [3.9] bpo-40985: Show correct SyntaxError text when last line has a LINECONT (GH-20888) #20905
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-06-16.00:29:43.716>
    created_at = <Date 2020-06-15.13:45:34.949>
    labels = ['interpreter-core', 'type-bug', '3.9', '3.10']
    title = 'PEG Parser: SyntaxError text empty when last line has a LINECONT'
    updated_at = <Date 2020-06-16.00:46:51.179>
    user = 'https://github.com/lysnikolaou'

    bugs.python.org fields:

    activity = <Date 2020-06-16.00:46:51.179>
    actor = 'miss-islington'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-06-16.00:29:43.716>
    closer = 'lys.nikolaou'
    components = ['Interpreter Core']
    creation = <Date 2020-06-15.13:45:34.949>
    creator = 'lys.nikolaou'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40985
    keywords = ['patch']
    message_count = 6.0
    messages = ['371544', '371545', '371547', '371584', '371609', '371610']
    nosy_count = 4.0
    nosy_names = ['gvanrossum', 'lys.nikolaou', 'pablogsal', 'miss-islington']
    pr_nums = ['20888', '20905']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue40985'
    versions = ['Python 3.9', 'Python 3.10']

    @lysnikolaou
    Copy link
    Contributor Author

    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

    @lysnikolaou lysnikolaou added 3.9 only security fixes 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jun 15, 2020
    @lysnikolaou
    Copy link
    Contributor Author

    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

    @lysnikolaou
    Copy link
    Contributor Author

    I keep doing something wrong. I hope it is clean by now what the difference is.

    @gvanrossum
    Copy link
    Member

    Yes, it's clear. :-) This is one reason we need to migrate off bpo and onto GitHub.

    @pablogsal
    Copy link
    Member

    New changeset 113e2b0 by Lysandros Nikolaou in branch 'master':
    bpo-40985: Show correct SyntaxError text when last line has a LINECONT (GH-20888)
    113e2b0

    @miss-islington
    Copy link
    Contributor

    New changeset 097b8b6 by Miss Islington (bot) in branch '3.9':
    bpo-40985: Show correct SyntaxError text when last line has a LINECONT (GH-20888)
    097b8b6

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants