Skip to content

SyntaxError location for *args in class bases is inconsistent #93165

Description

@tusharsadhwani

Code snippet:

class C(list[int]): ...

On Python 3.9:

>>> class C(list[*a]): ...
  File "<stdin>", line 1
    class C(list[*a]): ...
                   ^
SyntaxError: invalid syntax
>>> 

On Python 3.10:

>>> class C(list[*a]): ...
  File "<stdin>", line 1
    class C(list[*a]): ...
           ^
SyntaxError: expected ':'
>>>

I'd have expected it to point directly at the * in both cases.

Activity

  1. AlexWaygood commented on May 24, 2022

    @AlexWaygood
    Member

    Reproduced on 3.9/3.10 (but not on 3.11, where this isn't a SyntaxError at all due to PEP 646).

    Cc. @pablogsal

  2. wookie184 commented on May 26, 2022

    @wookie184
    Contributor

    I believe this is a specific case of #92858, which is fixed by #92894

  3. tusharsadhwani commented on May 29, 2022

    @tusharsadhwani
    ContributorAuthor

    Correct, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10 (EOL)end of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions