-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed as not planned
Labels
3.10only security fixesonly security fixes3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement
Description
Ran into this today. If you forget to close parentheses as part of a call in the header of a for
, with
, or class
statement (maybe others too?), the SyntaxError
seems to indicate that you forgot a colon:
>>> for foo in bar(baz:
File "<stdin>", line 1
for foo in bar(baz:
^
SyntaxError: expected ':'
It's not wrong, but could probably be improved. I personally find the pre-3.10 behavior more helpful:
>>> bar(baz:
File "<stdin>", line 1
for foo in bar(baz:
^
SyntaxError: invalid syntax
Even better, though, would be a "smarter" error message like the existing ones we have for unclosed parentheses:
>>> bar(baz:
File "<stdin>", line 1
for foo in bar(baz:
^
SyntaxError: '(' was never closed
Metadata
Metadata
Assignees
Labels
3.10only security fixesonly security fixes3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement