diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-28 01:56:53 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-28 01:56:53 (GMT) |
commit | 46c759d76d02cb873bae55fac37dfe71750e3bef (patch) | |
tree | 42418ab91cb39107010584ef758513f2f03179a5 /Lib/inspect.py | |
parent | 68fe9aa58c139e3a6f8c9188760bb237added7d6 (diff) | |
download | cpython-46c759d76d02cb873bae55fac37dfe71750e3bef.zip cpython-46c759d76d02cb873bae55fac37dfe71750e3bef.tar.gz cpython-46c759d76d02cb873bae55fac37dfe71750e3bef.tar.bz2 |
Issue 24298: Fix signature() to properly unwrap wrappers around bound methods
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index a91f749..49e66ce 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -1911,6 +1911,14 @@ def _signature_internal(obj, follow_wrapper_chains=True, skip_bound_arg=True): # Was this function wrapped by a decorator? if follow_wrapper_chains: obj = unwrap(obj, stop=(lambda f: hasattr(f, "__signature__"))) + if isinstance(obj, types.MethodType): + # If the unwrapped object is a *method*, we might want to + # skip its first parameter (self). + # See test_signature_wrapped_bound_method for details. + return _signature_internal( + obj, + follow_wrapper_chains=follow_wrapper_chains, + skip_bound_arg=skip_bound_arg) try: sig = obj.__signature__ |