diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-10 12:59:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-10 12:59:25 (GMT) |
commit | e6f066af2e15b4da17866a375e11010535d9c692 (patch) | |
tree | 8584a33204b0c1828d36c4daf1b1b4622f2a9b53 /Lib/inspect.py | |
parent | ee405e3b23c85eedf0413f87e74d06e0128a0298 (diff) | |
download | cpython-e6f066af2e15b4da17866a375e11010535d9c692.zip cpython-e6f066af2e15b4da17866a375e11010535d9c692.tar.gz cpython-e6f066af2e15b4da17866a375e11010535d9c692.tar.bz2 |
gh-74044: inspect.signature for wrappers around decorated bound methods (GH-736)
(cherry picked from commit dbf2faf579b4094387d65ee41f049456ca67c446)
Co-authored-by: Anton Ryzhov <anton@ryzhov.me>
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 60740c6..ad16f5c 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -2406,7 +2406,10 @@ def _signature_from_callable(obj, *, # Was this function wrapped by a decorator? if follow_wrapper_chains: - obj = unwrap(obj, stop=(lambda f: hasattr(f, "__signature__"))) + # Unwrap until we find an explicit signature or a MethodType (which will be + # handled explicitly below). + obj = unwrap(obj, stop=(lambda f: hasattr(f, "__signature__") + or isinstance(f, types.MethodType))) if isinstance(obj, types.MethodType): # If the unwrapped object is a *method*, we might want to # skip its first parameter (self). |