diff -r 87509d71653b Lib/inspect.py --- a/Lib/inspect.py Wed May 27 11:08:46 2015 -0400 +++ b/Lib/inspect.py Wed May 27 15:58:33 2015 -0400 @@ -2129,7 +2129,17 @@ # Was this function wrapped by a decorator? if follow_wrapper_chains: - obj = unwrap(obj, stop=(lambda f: hasattr(f, "__signature__"))) + obj = unwrap(obj, stop=(lambda f: hasattr(f, "__signature__") or + isinstance(f, types.MethodType))) + if isinstance(obj, types.MethodType): + # If during unwrapping we've encountered a decorated *method*, + # we might want to skip its first parameter (self). + # See test_signature_wrapped_bound_method for details. + return _signature_from_callable( + obj, + follow_wrapper_chains=follow_wrapper_chains, + skip_bound_arg=skip_bound_arg, + sigcls=sigcls) try: sig = obj.__signature__ diff -r 87509d71653b Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Wed May 27 11:08:46 2015 -0400 +++ b/Lib/test/test_inspect.py Wed May 27 15:58:33 2015 -0400 @@ -2086,6 +2086,19 @@ with self.assertRaisesRegex(ValueError, 'invalid method signature'): self.signature(Test()) + def test_signature_wrapped_bound_method(self): + # Issue 24298 + class Test: + def m1(self, arg1, arg2=1) -> int: + pass + @functools.wraps(Test().m1) + def m1d(*args, **kwargs): + pass + self.assertEqual(self.signature(m1d), + ((('arg1', ..., ..., "positional_or_keyword"), + ('arg2', 1, ..., "positional_or_keyword")), + int)) + def test_signature_on_classmethod(self): class Test: @classmethod