diff options
author | Anton Ryzhov <anton@ryzhov.me> | 2022-11-10 12:32:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-10 12:32:01 (GMT) |
commit | dbf2faf579b4094387d65ee41f049456ca67c446 (patch) | |
tree | 779bdc9a67884d980095027bb2a2d6495545ec3c /Lib/inspect.py | |
parent | 9d692841691590c25e6cf5b2250a594d3bf54825 (diff) | |
download | cpython-dbf2faf579b4094387d65ee41f049456ca67c446.zip cpython-dbf2faf579b4094387d65ee41f049456ca67c446.tar.gz cpython-dbf2faf579b4094387d65ee41f049456ca67c446.tar.bz2 |
gh-74044: inspect.signature for wrappers around decorated bound methods (GH-736)
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 f6750c3..d0015aa 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -2442,7 +2442,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). |