File tree Expand file tree Collapse file tree 3 files changed +738
-606
lines changed
Expand file tree Collapse file tree 3 files changed +738
-606
lines changed Original file line number Diff line number Diff line change @@ -1432,13 +1432,13 @@ invalid_import:
14321432 | 'import' token=NEWLINE {
14331433 RAISE_SYNTAX_ERROR_STARTING_FROM(token, "Expected one or more names after 'import'") }
14341434invalid_dotted_as_name:
1435- | a=dotted_name b=['as' NAME] c=dotted_name {
1435+ | a=dotted_name b=['as' NAME] c=dotted_name ('as' | ',' | ')' | ';' | NEWLINE) {
14361436 RAISE_SYNTAX_ERROR_KNOWN_RANGE(b ? (expr_ty) b : a, c, "expected comma between import clauses") }
14371437 | dotted_name 'as' !(NAME (',' | ')' | ';' | NEWLINE)) a=expression {
14381438 RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a,
14391439 "cannot use %s as import target", _PyPegen_get_expr_name(a)) }
14401440invalid_import_from_as_name:
1441- | [NAME 'as'] a=NAME b=NAME {
1441+ | [NAME 'as'] a=NAME b=NAME ('as' | ',' | ')' | ';' | NEWLINE) {
14421442 RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "expected comma between import clauses") }
14431443 | NAME 'as' !(NAME (',' | ')' | ';' | NEWLINE)) a=expression {
14441444 RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a,
Original file line number Diff line number Diff line change 22672267Traceback (most recent call last):
22682268SyntaxError: expected comma between import clauses
22692269
2270+ # Check that we don't raise the "missing comma" error for invalid import targets.
2271+
2272+ >>> import a b()
2273+ Traceback (most recent call last):
2274+ SyntaxError: invalid syntax
2275+
2276+ >>> from x import a b[c]
2277+ Traceback (most recent call last):
2278+ SyntaxError: invalid syntax
2279+
22702280>>> (): int
22712281Traceback (most recent call last):
22722282SyntaxError: only single target (not tuple) can be annotated
You can’t perform that action at this time.
0 commit comments