mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-138944: Fix SyntaxError message for invalid syntax following valid import-as statement (#138945)
This commit is contained in:
parent
9d34623eb1
commit
3dab11f888
4 changed files with 60 additions and 19 deletions
|
|
@ -2163,6 +2163,25 @@
|
|||
Traceback (most recent call last):
|
||||
SyntaxError: cannot use subscript as import target
|
||||
|
||||
# Check that we don't raise a "cannot use name as import target" error
|
||||
# if there is an error in an unrelated statement after ';'
|
||||
|
||||
>>> import a as b; None = 1
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: cannot assign to None
|
||||
|
||||
>>> import a, b as c; d = 1; None = 1
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: cannot assign to None
|
||||
|
||||
>>> from a import b as c; None = 1
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: cannot assign to None
|
||||
|
||||
>>> from a import b, c as d; e = 1; None = 1
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: cannot assign to None
|
||||
|
||||
# Check that we dont raise the "trailing comma" error if there is more
|
||||
# input to the left of the valid part that we parsed.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue