This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: inspect.signature does not support new functools.partialmethod
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: 20189 Superseder:
Assigned To: Nosy List: brett.cannon, larry, ncoghlan, python-dev, terry.reedy, yselivanov
Priority: normal Keywords: patch

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) * (Python committer) 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) * (Python committer) 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: Nick Coghlan (ncoghlan) * (Python committer) 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) * (Python committer) Date: 2014-01-23 18:11
> Reviewing the patch now.

Nick, can I push this?
msg209012 - (view) Author: Larry Hastings (larry) * (Python committer) 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) * (Python committer) 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: Nick Coghlan (ncoghlan) * (Python committer) 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: Nick Coghlan (ncoghlan) * (Python committer) 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) * (Python committer) Date: 2014-01-24 14:25
The patch from #20189 has landed.
msg209485 - (view) Author: Roundup Robot (python-dev) (Python triager) 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) * (Python committer) 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:56adminsetgithub: 64422
2014-01-27 22:29:56yselivanovsetstatus: open -> closed
resolution: fixed
messages: + msg209486
2014-01-27 22:29:05python-devsetnosy: + python-dev
messages: + msg209485
2014-01-27 02:40:14terry.reedylinkissue19903 dependencies
2014-01-24 14:25:47larrysetmessages: + msg209083
2014-01-24 13:58:13ncoghlansetdependencies: + inspect.Signature doesn't recognize all builtin types
messages: + msg209074
2014-01-24 13:56:36ncoghlansetmessages: + msg209073
2014-01-23 22:49:26yselivanovsetmessages: + msg209014
2014-01-23 22:38:25larrysetmessages: + msg209012
2014-01-23 18:11:12yselivanovsetmessages: + msg208972
2014-01-19 03:30:53ncoghlansetmessages: + msg208435
2014-01-17 23:49:22terry.reedysetstage: patch review
2014-01-17 23:49:11terry.reedysettype: enhancement -> behavior

messages: + msg208371
nosy: + terry.reedy
2014-01-11 21:22:59yselivanovcreate