[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-08 Thread Yury Selivanov
Changes by Yury Selivanov : -- resolution: -> fixed status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list U

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-08 Thread Roundup Robot
Roundup Robot added the comment: New changeset acbdbf2b06e0 by Yury Selivanov in branch '3.4': inspect.signautre: Fix functools.partial support. Issue #21117 http://hg.python.org/cpython/rev/acbdbf2b06e0 New changeset 21709cb4a8f5 by Yury Selivanov in branch 'default': inspect.signautre: Fix fun

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-04 Thread Yury Selivanov
Yury Selivanov added the comment: Any comments on the patch? -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-02 Thread Yury Selivanov
Yury Selivanov added the comment: Please review the attached patch. Here's the new partial signature semantics: foo(a, b, /, c, d, *args, e) partial(foo, 10) -> (b, /, c, d, *args, e) partial(foo, 10, c=11) -> (b, /, *, c=11, d, e) partial(foo, 10, 20, 30) -> (d, *args, e) parti

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-01 Thread Yury Selivanov
Yury Selivanov added the comment: > Oh, wait, it *does* have a usable signature. It's just that all the > *subsequent* positional-or-keyword parameters also have to be marked as > keyword-only. Interesting idea. I'll incorporate this logic into the patch. -- _

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-01 Thread Nick Coghlan
Nick Coghlan added the comment: Oh, wait, it *does* have a usable signature. It's just that all the *subsequent* positional-or-keyword parameters also have to be marked as keyword-only. -- ___ Python tracker

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-01 Thread Nick Coghlan
Nick Coghlan added the comment: Huh, that actually sounds like a possible design flaw in the core argument binding semantics. I'll have to think about that one some more. In the meantime, as far as this issue goes, I'm inclined to say that signature should throw an exception to be clear that s

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-01 Thread R. David Murray
R. David Murray added the comment: Oh, the error message comes from deep in the guts of python, yes. I'm saying that the fact that partial lets you write partial(foo, a='bar') when a is a positional argument is a bug. Even if other people agree with me (and they may not, "consenting adults"

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-01 Thread Yury Selivanov
Yury Selivanov added the comment: > Although, it looks like it's not something that partial is doing, it seems > like this call logic is implemented somewhere way deeper. Forget about what I said. Yes, it's a "bug" in partial. Fixing it, will require having the code from "Signature.bind" refl

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-01 Thread Yury Selivanov
Yury Selivanov added the comment: > First, I think this is a bug in partial, so I think we need to decide what, > if anything, to do about that first, before we decide if signature needs to > compensate for it or not. Agree. Although, it looks like it's not something that partial is doing, it

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-01 Thread R. David Murray
R. David Murray added the comment: We'll have to wait for Nick to chime in, but I'll make a couple of comments. First, I think this is a bug in partial, so I think we need to decide what, if anything, to do about that first, before we decide if signature needs to compensate for it or not.

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-01 Thread Yury Selivanov
Yury Selivanov added the comment: @R. David: Yes, thank you, David. Too bad I haven't seen your last messages before I started working on the patch... -- ___ Python tracker ___

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-01 Thread Yury Selivanov
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

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-01 Thread R. David Murray
R. David Murray added the comment: By "didn't know that was possible", I mean binding a positional argument as a keyword argument in the partial. If nobody else thought that was possible, maybe can just fix it :) -- ___ Python tracker

[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-01 Thread R. David Murray
R. David Murray added the comment: OK, I didn't even realize that was possible with partial. Now I understand Yuri's original point. His example is wrong: >>> def foo(a, b): ...print(a, b) >>> x2 = partial(foo, 'x') >>> str(inspect.signature(x2)) '(b)' This is the correct example: >>> x

[issue21117] inspect.signature: inaccuracies for partial functions

2014-03-31 Thread Nick Coghlan
Nick Coghlan added the comment: I believe Yury already figured out what I meant, but to make it entirely clear, after the change, this example: def foo(a, b): pass foo_partial = functools.partial(foo, 'spam') foo_partial2 = functools.partial(foo, a='spam') Should lead to the following