mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-118082: Improve import
without names syntax error message (#118083)
This commit is contained in:
parent
eb927e9fc8
commit
de1f686827
4 changed files with 219 additions and 149 deletions
|
@ -1299,10 +1299,14 @@ invalid_group:
|
|||
invalid_import:
|
||||
| a='import' ','.dotted_name+ 'from' dotted_name {
|
||||
RAISE_SYNTAX_ERROR_STARTING_FROM(a, "Did you mean to use 'from ... import ...' instead?") }
|
||||
| 'import' token=NEWLINE {
|
||||
RAISE_SYNTAX_ERROR_STARTING_FROM(token, "Expected one or more names after 'import'") }
|
||||
|
||||
invalid_import_from_targets:
|
||||
| import_from_as_names ',' NEWLINE {
|
||||
RAISE_SYNTAX_ERROR("trailing comma not allowed without surrounding parentheses") }
|
||||
| token=NEWLINE {
|
||||
RAISE_SYNTAX_ERROR_STARTING_FROM(token, "Expected one or more names after 'import'") }
|
||||
|
||||
invalid_compound_stmt:
|
||||
| a='elif' named_expression ':' { RAISE_SYNTAX_ERROR_STARTING_FROM(a, "'elif' must match an if-statement here") }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue