summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-05-28 01:59:03 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-05-28 01:59:03 (GMT)
commit507cd3cf91333d133241c8126d21c5e33001024c (patch)
treee8c25b37ea657486db628ca9f92fd4edbde74730 /Lib/inspect.py
parentd663cc4848bb42a5ef7d6d887ed3304d789d4141 (diff)
parent46c759d76d02cb873bae55fac37dfe71750e3bef (diff)
downloadcpython-507cd3cf91333d133241c8126d21c5e33001024c.zip
cpython-507cd3cf91333d133241c8126d21c5e33001024c.tar.gz
cpython-507cd3cf91333d133241c8126d21c5e33001024c.tar.bz2
Issue 24298: Fix signature() to properly unwrap wrappers around bound methods
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 3debc24..57cb3dc 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -2130,6 +2130,15 @@ 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__")))
+ 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_from_callable(
+ obj,
+ follow_wrapper_chains=follow_wrapper_chains,
+ skip_bound_arg=skip_bound_arg,
+ sigcls=sigcls)
try:
sig = obj.__signature__