Bug report
Bug description:
I just spent a couple of minutes figuring out what was wrong with this code:
import sys
print(
"\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
Bug report
Bug description:
I just spent a couple of minutes figuring out what was wrong with this code:
It produces the following error:
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