From 46c759d76d02cb873bae55fac37dfe71750e3bef Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Wed, 27 May 2015 21:56:53 -0400 Subject: Issue 24298: Fix signature() to properly unwrap wrappers around bound methods --- Lib/inspect.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Lib/inspect.py') diff --git a/Lib/inspect.py b/Lib/inspect.py index a91f749d52..49e66ce078 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__ -- cgit v1.2.1