Skip to content

Missing error: "parameter without a default follows parameter with a default" with a function that uses *args #129810

@adrien-lsh

Description

@adrien-lsh

Bug report

Bug description:

Hey there,

I don't know if that's a bug or if that's expected behavior, but since it's weird I might as well get this checked out.

>>> def f(*args, a = 0, b): pass
... 
>>> def f(a = 0, b): pass
  File "<python-input-1>", line 1
    def f(a = 0, b): pass
                 ^
SyntaxError: parameter without a default follows parameter with a default

I clearly understand the error here as it is not the first time I'm using Python, the thing that eludes me is: why is there no error with the first function ?

Thank you for your help !

CPython versions tested on:

3.13

Operating systems tested on:

Linux

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