Christoph Zwerschke <[email protected]> added the comment:
I can confirm that the problem still exists in Python 3.6.4 and 3.7.0a4.
Here is another way to demonstrate it:
Create the following file test.py:
# test
hello = f"{world)}"
Note that there is a syntax error in the f-string in line 2 which has a closing
parentheses, but no opening one.
Import this from Python 3.6.4 or 3.7.0a4:
>>> import test
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<fstring>", line 1
(world))
^
SyntaxError: unexpected EOF while parsing
The problem here is that the error message does not contain the name of the
erroneous file (test.py), points to a wrong line (line 1 instead of line 2),
and also shows parentheses instead of braces around the word "world", which are
not there in the original code. This can make it hard to locate such errors.
Note that when there are other kinds of errors in the f-string, or other kinds
of "unexpected EOF" in the imported file, the errorenous file is usually
reported correctly in the error message. Only certain kinds of syntax errors in
f-strings seem to be problematic.
----------
nosy: +cito
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue31140>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com