Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failure in inspect.signature on unbound partialmethods #77190

Closed
anntzer mannequin opened this issue Mar 6, 2018 · 6 comments
Closed

Assertion failure in inspect.signature on unbound partialmethods #77190

anntzer mannequin opened this issue Mar 6, 2018 · 6 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@anntzer
Copy link
Mannequin

anntzer mannequin commented Mar 6, 2018

BPO 33009
Nosy @serhiy-storchaka, @1st1, @anntzer, @miss-islington
PRs
  • bpo-33009: Fix inspect.signature() for single-parameter partialmethods. #6004
  • [3.7] bpo-33009: Fix inspect.signature() for single-parameter partialmethods. (GH-6004) #6006
  • [3.6] bpo-33009: Fix inspect.signature() for single-parameter partialmethods. (GH-6004) #6007
  • 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 2018-03-06.18:49:27.672>
    created_at = <Date 2018-03-06.07:33:47.330>
    labels = ['3.7', '3.8', 'type-bug', 'library']
    title = 'Assertion failure in inspect.signature on unbound partialmethods'
    updated_at = <Date 2018-03-06.18:49:27.671>
    user = 'https://github.com/anntzer'

    bugs.python.org fields:

    activity = <Date 2018-03-06.18:49:27.671>
    actor = 'yselivanov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-03-06.18:49:27.672>
    closer = 'yselivanov'
    components = ['Library (Lib)']
    creation = <Date 2018-03-06.07:33:47.330>
    creator = 'Antony.Lee'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33009
    keywords = ['patch']
    message_count = 6.0
    messages = ['313309', '313310', '313340', '313345', '313354', '313356']
    nosy_count = 4.0
    nosy_names = ['serhiy.storchaka', 'yselivanov', 'Antony.Lee', 'miss-islington']
    pr_nums = ['6004', '6006', '6007']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue33009'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @anntzer
    Copy link
    Mannequin Author

    anntzer mannequin commented Mar 6, 2018

    The following example crashes Python 3.6:

        from functools import partialmethod
        import inspect
    
        class T:
            g = partialmethod((lambda self, x: x), 1)
    print(T().g())  # Correctly returns 1.
    print(T.g(T()))  # Correctly returns 1.
    print(inspect.signature(T.g))  # Crashes.
    

    with

      File "/usr/lib/python3.6/inspect.py", line 3036, in signature
        return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
      File "/usr/lib/python3.6/inspect.py", line 2786, in from_callable
        follow_wrapper_chains=follow_wrapped)
      File "/usr/lib/python3.6/inspect.py", line 2254, in _signature_from_callable
        assert first_wrapped_param is not sig_params[0]
    IndexError: tuple index out of range
    

    @anntzer anntzer mannequin added the stdlib Python modules in the Lib dir label Mar 6, 2018
    @serhiy-storchaka
    Copy link
    Member

    This is not a crash, but an assertion failure.

    The assertion was added in bpo-30149.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.8 only security fixes labels Mar 6, 2018
    @serhiy-storchaka serhiy-storchaka changed the title inspect.signature crashes on unbound partialmethods Assertion failure in inspect.signature on unbound partialmethods Mar 6, 2018
    @serhiy-storchaka serhiy-storchaka added the type-bug An unexpected behavior, bug, or error label Mar 6, 2018
    @1st1
    Copy link
    Member

    1st1 commented Mar 6, 2018

    Yeah, that assertion needs to be tweaked a little bit. Created a PR.

    @1st1
    Copy link
    Member

    1st1 commented Mar 6, 2018

    New changeset 8a38721 by Yury Selivanov in branch 'master':
    bpo-33009: Fix inspect.signature() for single-parameter partialmethods. (GH-6004)
    8a38721

    @miss-islington
    Copy link
    Contributor

    New changeset 112f799 by Miss Islington (bot) in branch '3.7':
    bpo-33009: Fix inspect.signature() for single-parameter partialmethods. (GH-6004)
    112f799

    @miss-islington
    Copy link
    Contributor

    New changeset 387a055 by Miss Islington (bot) in branch '3.6':
    bpo-33009: Fix inspect.signature() for single-parameter partialmethods. (GH-6004)
    387a055

    @1st1 1st1 closed this as completed Mar 6, 2018
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants