[issue46838] Parameters and arguments parser syntax error improvments

Terry J. Reedy report at bugs.python.org
Fri Feb 25 15:45:07 EST 2022


Terry J. Reedy <tjreedy at udel.edu> added the comment:

With two exceptions, nice suggestions if feasible.

>>> def foo(*args=None): pass
SyntaxError: * argument cannot have default value

>>> def foo(**kwargs=None): pass
SyntaxError: ** argument cannot have default value

Good.

>>> foo(*args=[0])
SyntaxError: cannot assign to iterable argument unpacking

>>> foo(**args={"a": None})
SyntaxError: cannot assign to keyword argument unpacking

Incomprehensible.  It seems to me that these should have same message as first two; message should not depend on proposed default.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46838>
_______________________________________


More information about the Python-bugs-list mailing list