New submission from Brian Shaginaw <bshaginaw...@gmail.com>:

>>> 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})>

----------
components: Library (Lib)
messages: 354683
nosy: brian.shaginaw
priority: normal
severity: normal
status: open
title: inspect.signature.bind does not correctly handle keyword argument with 
same name as positional-only parameter
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38478>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to