-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Open
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-parsertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Right now we have:
>>> import a as a b
File "<python-input-0>", line 1
import a as a b
^
SyntaxError: cannot use name as import target
>>> from x import a as a b
File "<python-input-1>", line 1
from x import a as a b
^
SyntaxError: cannot use name as import targetThis happens since these cases match these two rules.
One possible fix would be to add NAME to the list of not-matched tokens so that the current rules don't match this case.
However, I have an idea for a slightly nicer error. PR forthcoming.
cc @pablogsal @lysnikolaou @sobolevn
CPython versions tested on:
3.14, 3.15, CPython main branch
Operating systems tested on:
Linux
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-parsertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error