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: Assertion failure in inspect.signature on unbound partialmethods
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Antony.Lee, miss-islington, serhiy.storchaka, yselivanov
Priority: normal Keywords: patch

Created on 2018-03-06 07:33 by Antony.Lee, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6004 merged yselivanov, 2018-03-06 16:56
PR 6006 merged miss-islington, 2018-03-06 17:59
PR 6007 merged miss-islington, 2018-03-06 18:00
Messages (6)
msg313309 - (view) Author: Antony Lee (Antony.Lee) * Date: 2018-03-06 07:33
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
msg313310 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-06 08:05
This is not a crash, but an assertion failure.

The assertion was added in issue30149.
msg313340 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-03-06 16:56
Yeah, that assertion needs to be tweaked a little bit.  Created a PR.
msg313345 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-03-06 17:59
New changeset 8a387219bdfb6ee34928d6168ac42ca559f11c9a by Yury Selivanov in branch 'master':
bpo-33009: Fix inspect.signature() for single-parameter partialmethods. (GH-6004)
https://github.com/python/cpython/commit/8a387219bdfb6ee34928d6168ac42ca559f11c9a
msg313354 - (view) Author: miss-islington (miss-islington) Date: 2018-03-06 18:23
New changeset 112f799666bac1bdbb320840d5fda3132255eb5e by Miss Islington (bot) in branch '3.7':
bpo-33009: Fix inspect.signature() for single-parameter partialmethods. (GH-6004)
https://github.com/python/cpython/commit/112f799666bac1bdbb320840d5fda3132255eb5e
msg313356 - (view) Author: miss-islington (miss-islington) Date: 2018-03-06 18:48
New changeset 387a055261267f5fafd2c12eafef49759c94704f by Miss Islington (bot) in branch '3.6':
bpo-33009: Fix inspect.signature() for single-parameter partialmethods. (GH-6004)
https://github.com/python/cpython/commit/387a055261267f5fafd2c12eafef49759c94704f
History
Date User Action Args
2022-04-11 14:58:58adminsetgithub: 77190
2018-03-06 18:49:27yselivanovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-03-06 18:48:10miss-islingtonsetmessages: + msg313356
2018-03-06 18:23:51miss-islingtonsetnosy: + miss-islington
messages: + msg313354
2018-03-06 18:00:54miss-islingtonsetpull_requests: + pull_request5772
2018-03-06 17:59:56miss-islingtonsetpull_requests: + pull_request5771
2018-03-06 17:59:48yselivanovsetmessages: + msg313345
2018-03-06 16:56:56yselivanovsetmessages: + msg313340
2018-03-06 16:56:26yselivanovsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request5769
2018-03-06 08:05:04serhiy.storchakasetversions: + Python 3.7, Python 3.8
type: behavior

nosy: + yselivanov, serhiy.storchaka
title: inspect.signature crashes on unbound partialmethods -> Assertion failure in inspect.signature on unbound partialmethods
messages: + msg313310
stage: needs patch
2018-03-06 07:33:47Antony.Leecreate