New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
syntax error in multiline f-string produces ~40k spaces output #81614
Comments
For instance this file: foo = f"""{}
foo""" $ python3.8 --version --version
Python 3.8.0b1 (default, Jun 6 2019, 03:44:52)
[GCC 7.4.0]
$ python3.8 t.py | wc -c
File "t.py", line 1 <<snipped, but very very many spaces>>
SyntaxError: f-string: empty expression not allowed $ python3.8 t.py |& wc -c
49134 |
I can also trigger this with:
And so it seems not necessarily related to fstrings |
Debugging further, there's a token with a |
This looks like the same issue I mentioned here https://bugs.python.org/msg344764 |
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 |
just an f-string doesn't trigger this, there needs to be tokens before it |
OK, very obnoxious. Fix restores behavior above. |
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? |
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 |
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: """ and run python test.py from CPython master, you get $./python.exe test.py 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 >>> try:
... compile('"""\na', '<none>', 'exec')
... except SyntaxError as e:
... print(repr(e))
...
SyntaxError('EOF while scanning triple-quoted string literal', ('<none>', 2, 6, '"""\na\n')) |
seems unrelated and does the same on older versions of python:
I'd suggest a new issue or finding the dupe |
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: |
SyntaxError
indicator printing too many spaces for multi-line strings #14433SyntaxError
indicator printing too many spaces for multi-line strings (GH-14433) #15001Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: