You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
syntax error in multiline f-string produces ~40k spaces output #81614
Debugging further, there's a token with a multi_line_start pointing at uninitialized memory -- let's see if I can't track down where that gets set and fix it :)
changed the title [-]syntax error in f-string in multiline string produces ~40k spaces of output[/-][+]syntax error in multiline f-string produces ~40k spaces output[/+]on Jun 28, 2019
asottile commented on Jun 28, 2019
asottilemannequin
MannequinAuthor
More actions
just an f-string doesn't trigger this, there needs to be tokens before it
The initial issue has been fixed in master by the commit 5b94f35:
commit 5b94f3578c662d5f1ee90c0e6b81481d9ec82d89
Author: Anthony Sottile \<[email protected]\>
Date: Mon Jul 29 06:59:13 2019 -0700
Fix `SyntaxError` indicator printing too many spaces for multi-line strings (GH-14433)
Backport to 3.8: commit cf52bd0b9b1c1b7ecdd91e1ebebd15ae5c213a2c.
Thanks Anthony Sottile! I close the issue.
Activity
asottile commentedon Jun 27, 2019
For instance this file:
<<snipped, but very very many spaces>>
SyntaxError: f-string: empty expression not allowed
asottile commentedon Jun 27, 2019
I can also trigger this with:
And
python -Werrorso it seems not necessarily related to fstrings
asottile commentedon Jun 27, 2019
Debugging further, there's a token with a
multi_line_startpointing at uninitialized memory -- let's see if I can't track down where that gets set and fix it :)asmeurer commentedon Jun 27, 2019
This looks like the same issue I mentioned here https://bugs.python.org/msg344764
terryjreedy commentedon Jun 28, 2019
On Windows 10 with current 3.8 I see correct output, so the bug seems OS specific, even though the simple fix (see PR) is not.
C:\Users\Terry>py f:/python/a/tem4.py
File "f:/python/a/tem4.py", line 1
f'''{}
^
SyntaxError: f-string: empty expression not allowed
[-]syntax error in f-string in multiline string produces ~40k spaces of output[/-][+]syntax error in multiline f-string produces ~40k spaces output[/+]asottile commentedon Jun 28, 2019
just an f-string doesn't trigger this, there needs to be tokens before it
terryjreedy commentedon Jun 28, 2019
OK, very obnoxious. Fix restores behavior above.
pablogsal commentedon Jul 29, 2019
Thanks Anthony Sottile for the fix!
I suggest adding more test cases that do not involve f-strings, what do you think? Can you create another PR for those?
asottile commentedon Jul 29, 2019
sure! the only other case I could come up with involves multi-line strings and invalid escape sequences + Werror
let me see if I can fold that in as well
asmeurer commentedon Aug 3, 2019
This seems related. It's also possible I'm misunderstanding what is supposed to happen here.
If you create test.py with just the 2 lines:
"""
a
and run python test.py from CPython master, you get
$./python.exe test.py
File "/Users/aaronmeurer/Documents/cpython/test.py", line 4
a
^
SyntaxError: EOF while scanning triple-quoted string literal
Notice that it reports line 4 even though the file only has 2 lines.
The offset in the syntax error is 6 columns (line numbers and column offsets
in SyntaxErrors count from 1)
asottile commentedon Aug 3, 2019
seems unrelated and does the same on older versions of python:
I'd suggest a new issue or finding the dupe
vstinner commentedon Aug 21, 2019
The initial issue has been fixed in master by the commit 5b94f35:
If there is a different issue in Python 3.7 and you consider that it must be fixed, please file a new issue. Python 3.5 and 3.6 don't accept bugfixes anymore:
https://devguide.python.org/#status-of-python-branches