mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue 24298: Fix signature() to properly unwrap wrappers around bound methods
This commit is contained in:
commit
507cd3cf91
3 changed files with 25 additions and 0 deletions
|
@ -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__
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue