Message309773
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. |
|
Date |
User |
Action |
Args |
2018-01-10 16:33:44 | cito | set | recipients:
+ cito, eric.smith, chris.259263 |
2018-01-10 16:33:43 | cito | set | messageid: <1515602023.88.0.467229070634.issue31140@psf.upfronthosting.co.za> |
2018-01-10 16:33:43 | cito | link | issue31140 messages |
2018-01-10 16:33:43 | cito | create | |
|