classification
Title: pegen parser: Crash on SyntaxError with f-string on Windows
Type: crash Stage: resolved
Components: Interpreter Core Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lys.nikolaou, neonene, pablogsal
Priority: release blocker Keywords: patch

Created on 2021-01-20 22:51 by neonene, last changed 2021-01-31 23:32 by pablogsal. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24279 merged pablogsal, 2021-01-20 23:44
Messages (4)
msg385377 - (view) Author: neonene (neonene) * Date: 2021-01-20 22:51
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 (e5fe509054183bed9aef42c92da8407d339e8af8).

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'{.}'")
msg385379 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-01-20 23:29
Seems that this problem was introduced by e5fe509054183bed9aef42c92da8407d339e8af8
msg385382 - (view) Author: neonene (neonene) * Date: 2021-01-21 00:12
For me, I confirmed no crash with PR 24279.
Thanks for the fix in no time.
msg386044 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-01-31 22:48
New changeset 40901518167c66abc1ebc5b71c5b86d733cfa154 by Pablo Galindo in branch 'master':
bpo-42986: Fix parser crash when reporting syntax errors in f-string with newlines (GH-24279)
https://github.com/python/cpython/commit/40901518167c66abc1ebc5b71c5b86d733cfa154
History
Date User Action Args
2021-01-31 23:32:48pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-01-31 22:48:29pablogsalsetmessages: + msg386044
2021-01-25 22:32:28pablogsalsetpriority: normal -> release blocker
2021-01-21 00:12:03neonenesetmessages: + msg385382
2021-01-20 23:44:01pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request23102
2021-01-20 23:29:13pablogsalsetmessages: + msg385379
2021-01-20 22:51:26neonenecreate