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

pegen parser: Crash on SyntaxError with f-string on Windows #87152

Closed
neonene mannequin opened this issue Jan 20, 2021 · 4 comments
Closed

pegen parser: Crash on SyntaxError with f-string on Windows #87152

neonene mannequin opened this issue Jan 20, 2021 · 4 comments
Labels
3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@neonene
Copy link
Mannequin

neonene mannequin commented Jan 20, 2021

BPO 42986
Nosy @lysnikolaou, @pablogsal, @neonene
PRs
  • bpo-42986: Fix parser crash when reporting syntax errors in f-string with newlines #24279
  • 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 2021-01-31.23:32:48.973>
    created_at = <Date 2021-01-20.22:51:26.792>
    labels = ['interpreter-core', '3.10', 'type-crash', 'release-blocker']
    title = 'pegen parser: Crash on SyntaxError with f-string on Windows'
    updated_at = <Date 2021-01-31.23:32:48.972>
    user = 'https://github.com/neonene'

    bugs.python.org fields:

    activity = <Date 2021-01-31.23:32:48.972>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-01-31.23:32:48.973>
    closer = 'pablogsal'
    components = ['Interpreter Core']
    creation = <Date 2021-01-20.22:51:26.792>
    creator = 'neonene'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42986
    keywords = ['patch']
    message_count = 4.0
    messages = ['385377', '385379', '385382', '386044']
    nosy_count = 3.0
    nosy_names = ['lys.nikolaou', 'pablogsal', 'neonene']
    pr_nums = ['24279']
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue42986'
    versions = ['Python 3.10']

    @neonene
    Copy link
    Mannequin Author

    neonene mannequin commented Jan 20, 2021

    On Windows, Python master crashes using f-string (which has an invalid char with braces) on line 3 and after.
    It seems the issue is from commit (e5fe509).

    I tried

    1. exec("f'{.}'")
    2. exec("\nf'{.}'")
    3. exec("\n\nf'{.}'")

    commands and results are

    1) expected
        >>> exec("f'{.}'")
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
          File "<string>", line 1
            (.)
             ^
        SyntaxError: f-string: invalid syntax
    
    2) unexpected (caret indicates nothing)
        >>> exec("\nf'{.}'")
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
          File "<string>", line 2
        ^
    SyntaxError: f-string: invalid syntax
    
    3) python crashes
        >>> exec("\n\nf'{.}'")

    @neonene neonene mannequin added 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump labels Jan 20, 2021
    @pablogsal
    Copy link
    Member

    Seems that this problem was introduced by e5fe509

    @neonene
    Copy link
    Mannequin Author

    neonene mannequin commented Jan 21, 2021

    For me, I confirmed no crash with PR 24279.
    Thanks for the fix in no time.

    @pablogsal
    Copy link
    Member

    New changeset 4090151 by Pablo Galindo in branch 'master':
    bpo-42986: Fix parser crash when reporting syntax errors in f-string with newlines (GH-24279)
    4090151

    @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.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant