Skip to content

Incorrect syntax error message for incorrect argument unpacking #110696

Closed

Description

Bug report

Bug description:

I don't think SyntaxError: iterable argument unpacking follows keyword argument unpacking should be present in a case like this (minimal reproducible example):

>>> func(t, *:)
  File "<stdin>", line 1
    func(t, *:)
         ^
SyntaxError: iterable argument unpacking follows keyword argument unpacking

So it seems like if * is followed by code that triggers a generic SyntaxError: invalid syntax error, the former error triggers and overshadows the generic error. This has somewhat made checking the error in the expression following that * a bit harder.
I have another question. func(a=5, *b) is apparently allowed but from the error func(**{'a': 7}, *b) isn't? I don't know what the PEP is for this so I'll try to search it up later.

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Linked PRs

Activity

  1. Eclips4 commented on Oct 11, 2023

    @Eclips4
    Member
  2. added a commit that references this issue on Oct 11, 2023
  3. changed the title [-]Wrong error message?[/-] [+]Incorrect syntax error message for incorrect argument unpacking[/+] on Oct 11, 2023
  4. added a commit that references this issue on Oct 11, 2023
  5. added a commit that references this issue on Oct 12, 2023
  6. thatbirdguythatuknownot commented on Oct 12, 2023

    @thatbirdguythatuknownot
    ContributorAuthor

    As for my question, it seems that func(a=5, *b) shouldn't be valid? All the other alternative ways to write it are invalid syntax.

    # not allowed
    func(a=5, 1, 2)
    func(**{'a': 5}, 1, 2)
    func(**{'a': 5}, *(1, 2))
    # allowed
    func(a=7, *(1, 2))

    I might have to follow this up with a different issue.

  7. added 2 commits that reference this issue on Oct 12, 2023
  8. pablogsal commented on Oct 12, 2023

    @pablogsal
    Member

    As for my question, it seems that func(a=5, *b) shouldn't be valid? All the other alternative ways to write it are invalid syntax.

    It was valid before (3.9 and older) so we cannot just make invalid now for backwards compatibility reasons.

  9. added 3 commits that reference this issue on Oct 12, 2023
  10. added a commit that references this issue on Sep 2, 2024
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

    interpreter-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