Message354683
>>> import inspect
>>> def foo(bar, /, **kwargs):
... print(bar, kwargs)
...
>>> foo(1, bar=2)
1 {'bar': 2}
>>> inspect.signature(foo).bind(1, bar=2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/inspect.py", line 3025, in bind
return self._bind(args, kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/inspect.py", line 2964, in _bind
raise TypeError(
TypeError: multiple values for argument 'bar'
Python 3.8 introduced positional-only parameters, which allow parameter names to remain available for use in **kwargs. It looks like `inspect.signature.bind` does not recognize this, and thinks the parameter is being passed twice, which causes the above TypeError.
Expected result: <BoundArguments (bar=1, kwargs={'bar': 2})> |
|
Date |
User |
Action |
Args |
2019-10-15 02:26:32 | brian.shaginaw | set | recipients:
+ brian.shaginaw |
2019-10-15 02:26:32 | brian.shaginaw | set | messageid: <1571106392.69.0.85003046785.issue38478@roundup.psfhosted.org> |
2019-10-15 02:26:32 | brian.shaginaw | link | issue38478 messages |
2019-10-15 02:26:32 | brian.shaginaw | create | |
|