File tree Expand file tree Collapse file tree 4 files changed +219
-149
lines changed
Misc/NEWS.d/next/Core and Builtins Expand file tree Collapse file tree 4 files changed +219
-149
lines changed Original file line number Diff line number Diff line change @@ -1299,10 +1299,14 @@ invalid_group:
12991299invalid_import:
13001300 | a='import' ','.dotted_name+ 'from' dotted_name {
13011301 RAISE_SYNTAX_ERROR_STARTING_FROM(a, "Did you mean to use 'from ... import ...' instead?") }
1302+ | 'import' token=NEWLINE {
1303+ RAISE_SYNTAX_ERROR_STARTING_FROM(token, "Expected one or more names after 'import'") }
13021304
13031305invalid_import_from_targets:
13041306 | import_from_as_names ',' NEWLINE {
13051307 RAISE_SYNTAX_ERROR("trailing comma not allowed without surrounding parentheses") }
1308+ | token=NEWLINE {
1309+ RAISE_SYNTAX_ERROR_STARTING_FROM(token, "Expected one or more names after 'import'") }
13061310
13071311invalid_compound_stmt:
13081312 | a='elif' named_expression ':' { RAISE_SYNTAX_ERROR_STARTING_FROM(a, "'elif' must match an if-statement here") }
Original file line number Diff line number Diff line change 16991699Traceback (most recent call last):
17001700SyntaxError: invalid syntax
17011701
1702+ >>> from i import
1703+ Traceback (most recent call last):
1704+ SyntaxError: Expected one or more names after 'import'
1705+
1706+ >>> from .. import
1707+ Traceback (most recent call last):
1708+ SyntaxError: Expected one or more names after 'import'
1709+
1710+ >>> import
1711+ Traceback (most recent call last):
1712+ SyntaxError: Expected one or more names after 'import'
1713+
17021714>>> (): int
17031715Traceback (most recent call last):
17041716SyntaxError: only single target (not tuple) can be annotated
Original file line number Diff line number Diff line change 1+ Improve :exc: `SyntaxError ` message for imports without names, like in
2+ ``from x import `` and ``import `` cases. It now points
3+ out to users that :keyword: `import ` expects at least one name after it.
You can’t perform that action at this time.
0 commit comments