This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author slavkostrov
Recipients slavkostrov
Date 2021-01-16.16:30:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1610814652.94.0.812646879341.issue42940@roundup.psfhosted.org>
In-reply-to
Content
>>> def foo(a, /, b=1, **kwargs): pass
...
>>> foo(a=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: foo() missing 1 required positional argument: 'a'

>>> inspect.signature(foo).bind(a=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "\Python\Python39\lib\inspect.py", line 3062, in bind
    return self._bind(args, kwargs)
  File "\Python\Python39\lib\inspect.py", line 2958, in _bind
    raise TypeError(msg) from None
TypeError: 'a' parameter is positional only, but was passed as a keyword

There is a different behaviour between a simple function call and inspect.signature(foo).bind - different TypeError messages.

I think inspect should check for VARKEYWORDS before throwing an error and throw only if there are not.
History
Date User Action Args
2021-01-16 16:30:52slavkostrovsetrecipients: + slavkostrov
2021-01-16 16:30:52slavkostrovsetmessageid: <1610814652.94.0.812646879341.issue42940@roundup.psfhosted.org>
2021-01-16 16:30:52slavkostrovlinkissue42940 messages
2021-01-16 16:30:52slavkostrovcreate