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: Unusable syntax error reported when Python keyword in a f-string
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Improve error reporting involving f-strings (PEP 498)
View: 29051
Assigned To: Nosy List: Dmitry sky, eric.smith, r.david.murray
Priority: normal Keywords:

Created on 2017-12-19 15:59 by Dmitry sky, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fstring.py Dmitry sky, 2017-12-19 15:59
Messages (3)
msg308657 - (view) Author: Dmitry sky (Dmitry sky) Date: 2017-12-19 15:59
def get_search_url(from_, to):
    return f"http://thesite.com/Search?SO0={from_}&SD0={to}&SD1={from}&NA=false"
#   pls note `from_` vs `from`                                  ^^^^^^


$ python fstring.py
  File "<fstring>", line 1
    (from)
        ^
SyntaxError: invalid syntax


Should report real line #.
msg308659 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2017-12-19 16:11
Yes, this is a real problem. I think there's already an issue for this, but I can't find it.

Unfortunately, to fix it requires a bit of refactoring on how line numbers and errors are tracked. It's on my list of things to do.
msg308684 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-12-19 21:08
The existing issue is #29051.
History
Date User Action Args
2022-04-11 14:58:55adminsetgithub: 76557
2017-12-19 21:08:10r.david.murraysetstatus: open -> closed

superseder: Improve error reporting involving f-strings (PEP 498)

nosy: + r.david.murray
messages: + msg308684
resolution: duplicate
stage: needs patch -> resolved
2017-12-19 16:11:45eric.smithsetnosy: + eric.smith

messages: + msg308659
stage: needs patch
2017-12-19 15:59:56Dmitry skycreate