mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-74044: inspect.signature for wrappers around decorated bound methods (GH-736)
(cherry picked from commit dbf2faf579
)
Co-authored-by: Anton Ryzhov <anton@ryzhov.me>
This commit is contained in:
parent
921f235367
commit
1de088ca95
3 changed files with 12 additions and 3 deletions
|
@ -2457,7 +2457,10 @@ 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__")))
|
||||
# Unwrap until we find an explicit signature or a MethodType (which will be
|
||||
# handled explicitly below).
|
||||
obj = unwrap(obj, stop=(lambda f: hasattr(f, "__signature__")
|
||||
or isinstance(f, types.MethodType)))
|
||||
if isinstance(obj, types.MethodType):
|
||||
# If the unwrapped object is a *method*, we might want to
|
||||
# skip its first parameter (self).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue