Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-parsertype-featureA feature request or enhancementA feature request or enhancement
Description
Bug report
Bug description:
I just spent a couple of minutes figuring out what was wrong with this code:
importsysprint( "\n""Notice: a Git repository with 'main' and 'doc' branches has been set up.\n""You will probably want to amend the initial commit on the 'main' branch.\n"file=sys.stderr )It produces the following error:
File "/tmp/tmp.py", line 4 "\n" ^^^^ SyntaxError: invalid syntax. Perhaps you forgot a comma? Which had me looking at the "\n" line and trying to confirm if Python even has string literal concatenation like I seemed to remember (it does). The error was actually two lines further down, at the end of the concatenated string literal: that line was missing the comma (fix).
Would it be possible to improve the error message, moving it to the last line of the string literal that doesn’t have a comma?
CPython versions tested on:
3.14, 3.13, 3.15
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-parsertype-featureA feature request or enhancementA feature request or enhancement