[New-bugs-announce] [issue42940] Incorrect behavior of inspect.signature(f).bind
Slava Kostrov
report at bugs.python.org
Sat Jan 16 11:30:52 EST 2021
New submission from Slava Kostrov <slavkostrov at gmail.com>:
>>> 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.
----------
messages: 385143
nosy: slavkostrov
priority: normal
severity: normal
status: open
title: Incorrect behavior of inspect.signature(f).bind
type: behavior
versions: Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42940>
_______________________________________
More information about the New-bugs-announce
mailing list