[New-bugs-announce] [issue38964] Output of syntax error in f-string contains wrong filename
Erik Cederstrand
report at bugs.python.org
Wed Dec 4 03:27:53 EST 2019
New submission from Erik Cederstrand <erik at cederstrand.dk>:
When I have a normal syntax error in a file, Python reports the filename in the exception output:
$ cat syntax_error.py
0x=5
$ python3.8 syntax_error.py
File "syntax_error.py", line 1
0x=5
^
SyntaxError: invalid hexadecimal literal
But if the syntax error is inside an f-string, Python reports 'File "<fstring>"' instead of the actual filename in the exception output.
$ cat syntax_error_in_fstring.py
f'This is a syntax error: {0x=5}'
$ python3.8 syntax_error_in_fstring.py
File "<fstring>", line 1
SyntaxError: invalid hexadecimal literal
----------
messages: 357777
nosy: Erik Cederstrand
priority: normal
severity: normal
status: open
title: Output of syntax error in f-string contains wrong filename
type: behavior
versions: Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38964>
_______________________________________
More information about the New-bugs-announce
mailing list