Skip to content

inspect.signature does not support new functools.partialmethod #64422

Closed

Description

@1st1
BPO 20223
Nosy @brettcannon, @terryjreedy, @ncoghlan, @larryhastings, @1st1
Dependencies
  • bpo-20189: inspect.Signature doesn't recognize all builtin types
  • Files
  • signature_partialmeth_01.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2014-01-27.22:29:56.377>
    created_at = <Date 2014-01-11.21:22:59.504>
    labels = ['type-bug', 'library']
    title = 'inspect.signature does not support new functools.partialmethod'
    updated_at = <Date 2014-01-27.22:29:56.376>
    user = 'https://github.com/1st1'

    bugs.python.org fields:

    activity = <Date 2014-01-27.22:29:56.376>
    actor = 'yselivanov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-01-27.22:29:56.377>
    closer = 'yselivanov'
    components = ['Library (Lib)']
    creation = <Date 2014-01-11.21:22:59.504>
    creator = 'yselivanov'
    dependencies = ['20189']
    files = ['33418']
    hgrepos = []
    issue_num = 20223
    keywords = ['patch']
    message_count = 11.0
    messages = ['207915', '208371', '208435', '208972', '209012', '209014', '209073', '209074', '209083', '209485', '209486']
    nosy_count = 6.0
    nosy_names = ['brett.cannon', 'terry.reedy', 'ncoghlan', 'larry', 'python-dev', 'yselivanov']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue20223'
    versions = ['Python 3.4']

    Activity

    1. 1st1 commented on Jan 11, 2014

      @1st1
      MemberAuthor

      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)'.

    2. added
      type-featureA feature request or enhancement
      stdlibStandard Library Python modules in the Lib/ directory
      on Jan 11, 2014
    3. terryjreedy commented on Jan 17, 2014

      @terryjreedy
      Member

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

    4. added
      type-bugAn unexpected behavior, bug, or error
      and removed
      type-featureA feature request or enhancement
      on Jan 17, 2014
    5. ncoghlan commented on Jan 19, 2014

      @ncoghlan
      Contributor

      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.

    6. 1st1 commented on Jan 23, 2014

      @1st1
      MemberAuthor

      Reviewing the patch now.

      Nick, can I push this?

    7. larryhastings commented on Jan 23, 2014

      @larryhastings
      Contributor

      I'm not sure why you're asking Nick. Is he the release manager for 3.4?

    8. 1st1 commented on Jan 23, 2014

      @1st1
      MemberAuthor

      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.

    9. ncoghlan commented on Jan 24, 2014

      @ncoghlan
      Contributor

      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.

    10. ncoghlan commented on Jan 24, 2014

      @ncoghlan
      Contributor

      As far as pushing goes, I'd wait until Larry lands bpo-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 :)

    11. larryhastings commented on Jan 24, 2014

      @larryhastings
      Contributor

      The patch from bpo-20189 has landed.

    12. python-dev commented on Jan 27, 2014

      python-devmannequin
      Mannequin

      New changeset baedc256999a by Yury Selivanov in branch 'default':
      inspect.signature: Add support for 'functools.partialmethod' bpo-20223
      http://hg.python.org/cpython/rev/baedc256999a

    13. 1st1 commented on Jan 27, 2014

      @1st1
      MemberAuthor

      Thanks for the review, Nick.
      Closing the issue now.

    14. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions