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 target
This 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
Bug report
Bug description:
Right now we have:
This happens since these cases match these two rules.
One possible fix would be to add
NAMEto 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