python / cpython

The Python programming language
https://www.python.org
Other
62.15k stars 29.87k forks source link

Location and text of f-string unclosed quote error is incorrect #104658

Closed pablogsal closed 1 year ago

pablogsal commented 1 year ago

Since the PEP 701 changes the error of unclosed triple quited f-string literals is now incorrect:

x = 1 + 1
y = 2 + 2
z = f"""
sdfjnsdfjsdf
sdfsdfs{1+
2}dfigdf {3+
4}sdufsd
""

Executing this file will show:

  File "/Users/pgalindo3/github/python/python_tokenizer_marta/lol.py", line 8
    4}sdufsd
        ^
SyntaxError: unterminated triple-quoted f-string literal (detected at line 13)

both the line number and the text are wrong.

Linked PRs

pablogsal commented 1 year ago

CC: @lysnikolaou @isidentical @mgmacias95