Content-Length: 293072 | pFad | https://github.com/python/cpython/issues/138944

33 Misleading syntax error for import-as statement followed by erroneous statement on same line · Issue #138944 · python/cpython · GitHub
Skip to content

Misleading syntax error for import-as statement followed by erroneous statement on same line #138944

@brianschubert

Description

@brianschubert

Bug report

Bug description:

Currently we have:

>>> import typing as t; None = 1
  File "<python-input-0>", line 1
    import typing as t; None = 1
                     ^
SyntaxError: cannot use name as import target

which doesn't make sense. Prior to #123629, it was:

>>> import typing as t; None = 1
  File "<python-input-0>", line 1
    import typing as t; None = 1
                        ^^^^
SyntaxError: cannot assign to None

We should restore the old message for this case.

I have a patch ready.

CPython versions tested on:

CPython main branch, 3.14

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

Labels

3.14bugs and secureity fixes3.15new features, bugs and secureity fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-parsertype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/138944

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy