mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
inspect.signature: Add support for decorated (wrapped) builtins #20425
This commit is contained in:
parent
b77511da92
commit
76c6c593ed
2 changed files with 18 additions and 3 deletions
|
@ -1530,9 +1530,6 @@ def signature(obj):
|
|||
if not callable(obj):
|
||||
raise TypeError('{!r} is not a callable object'.format(obj))
|
||||
|
||||
if _signature_is_builtin(obj):
|
||||
return Signature.from_builtin(obj)
|
||||
|
||||
if isinstance(obj, types.MethodType):
|
||||
# In this case we skip the first parameter of the underlying
|
||||
# function (usually `self` or `cls`).
|
||||
|
@ -1570,6 +1567,9 @@ def signature(obj):
|
|||
|
||||
return sig.replace(parameters=new_params)
|
||||
|
||||
if _signature_is_builtin(obj):
|
||||
return Signature.from_builtin(obj)
|
||||
|
||||
if isinstance(obj, types.FunctionType):
|
||||
return Signature.from_function(obj)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue