Issue 20223: inspect.signature does not support new functools.partialmethod
Created on 2014-01-11 21:22 by yselivanov, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| signature_partialmeth_01.patch | yselivanov, 2014-01-11 21:22 | review | ||
| Messages (11) | |||
|---|---|---|---|
| msg207915 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2014-01-11 21:22 | |
new and handy functools.partialmethod doesn't fully support inspect.signature.
For instance, for the following code:
class Spam:
def say(self, a, b=1):
print(a)
hello = functools.partialmethod(say, 'hello')
the 'signature(Spam.hello)' will always return '(*args, **keywords)'
I'm attaching a patch that fixes that, so the signature for the above example will be '(self, b=1)'.
|
|||
| msg208371 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2014-01-17 23:49 | |
This strikes me as a bug introduced with the new 3.4 feature and thus a Type: behavior issue eligible for 3.4. inspect.signature should work correctly with any python-coded callable and not return a wrong answer. (And we are trying to get inspect to work with C-coded callables also in 3.4.) |
|||
| msg208435 - (view) | Author: Alyssa Coghlan (ncoghlan) * ![]() |
Date: 2014-01-19 03:30 | |
Aye, I agree with Terry that this is a behavioural bug introduced with the new partialmethod feature - we missed adding a new test case to check that inspect.signature handled it properly. Reviewing the patch now. |
|||
| msg208972 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2014-01-23 18:11 | |
> Reviewing the patch now. Nick, can I push this? |
|||
| msg209012 - (view) | Author: Larry Hastings (larry) * ![]() |
Date: 2014-01-23 22:38 | |
I'm not sure why you're asking Nick. Is he the release manager for 3.4? |
|||
| msg209014 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2014-01-23 22:49 | |
> I'm not sure why you're asking Nick. Is he the release manager for 3.4? I'm asking him because he wrote "Reviewing the patch now.", and I thought that he might have actually seen the patch already. I'm more than fine if anyone else reviews the patch, really. |
|||
| msg209073 - (view) | Author: Alyssa Coghlan (ncoghlan) * ![]() |
Date: 2014-01-24 13:56 | |
Yury, I believe the review comments from Rietveld go to the address you have registered as primary in the tracker, so that's currently your address with the ".ml" suffix rather than your main one. My only suggestion was to use ._partialmethod for the attribute name, rather than __partialmethod__, since this feels a bit more like an ordinary private attribute, rather than a new protocol. Lots of introspection tools deliberately *display* dunder names, and that doesn't really feel appropriate here. |
|||
| msg209074 - (view) | Author: Alyssa Coghlan (ncoghlan) * ![]() |
Date: 2014-01-24 13:58 | |
As far as pushing goes, I'd wait until Larry lands issue 20189 - I suspect there's a risk of conflict between these patches in the inspect module, and that one is key to getting builtin signatures supported properly :) |
|||
| msg209083 - (view) | Author: Larry Hastings (larry) * ![]() |
Date: 2014-01-24 14:25 | |
The patch from #20189 has landed. |
|||
| msg209485 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2014-01-27 22:29 | |
New changeset baedc256999a by Yury Selivanov in branch 'default': inspect.signature: Add support for 'functools.partialmethod' #20223 http://hg.python.org/cpython/rev/baedc256999a |
|||
| msg209486 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2014-01-27 22:29 | |
Thanks for the review, Nick. Closing the issue now. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:56 | admin | set | github: 64422 |
| 2014-01-27 22:29:56 | yselivanov | set | status: open -> closed resolution: fixed messages: + msg209486 |
| 2014-01-27 22:29:05 | python-dev | set | nosy:
+ python-dev messages: + msg209485 |
| 2014-01-27 02:40:14 | terry.reedy | link | issue19903 dependencies |
| 2014-01-24 14:25:47 | larry | set | messages: + msg209083 |
| 2014-01-24 13:58:13 | ncoghlan | set | dependencies:
+ inspect.Signature doesn't recognize all builtin types messages: + msg209074 |
| 2014-01-24 13:56:36 | ncoghlan | set | messages: + msg209073 |
| 2014-01-23 22:49:26 | yselivanov | set | messages: + msg209014 |
| 2014-01-23 22:38:25 | larry | set | messages: + msg209012 |
| 2014-01-23 18:11:12 | yselivanov | set | messages: + msg208972 |
| 2014-01-19 03:30:53 | ncoghlan | set | messages: + msg208435 |
| 2014-01-17 23:49:22 | terry.reedy | set | stage: patch review |
| 2014-01-17 23:49:11 | terry.reedy | set | type: enhancement -> behavior messages:
+ msg208371 |
| 2014-01-11 21:22:59 | yselivanov | create | |

