[issue21117] inspect.signature: inaccuracies for partial functions
Yury Selivanov
report at bugs.python.org
Tue Apr 1 17:14:32 CEST 2014
Yury Selivanov added the comment:
@Nick:
Ouch... I'm halfway through the implementation, and it seems like your idea isn't going to work.
Example (from unittest):
def foo(a=1, b=2, c=3): pass
_foo = partial(foo, a=10, c=13)
Now, the signature for "_foo", with your logic applied, will be:
(b=2, *, a=10, c=13)
If, however, you try to do the following call:
_foo(11)
It will fail with a TypeError "got multiple values for argument 'a'", because 'partial' will actually do this call:
foo(11, a=10, c=13)
I now remember this obstacle, that's why I have '_partial_kwarg'. So unfortunately, why I really like your idea, I don't think we can make it work.
Now, I still want to get rid the '_partial_kwarg' attribute. Are you guys OK, if I introduce PartialParameter & PartialSignature classes?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21117>
_______________________________________
More information about the Python-bugs-list
mailing list