mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
inspect.signature: Check for function-like objects before builtins. Issue #17159
This commit is contained in:
parent
8c8b4e0ebf
commit
a773de040d
2 changed files with 20 additions and 4 deletions
|
@ -1911,15 +1911,15 @@ def _signature_internal(obj, follow_wrapper_chains=True, skip_bound_arg=True):
|
|||
|
||||
return sig.replace(parameters=new_params)
|
||||
|
||||
if _signature_is_builtin(obj):
|
||||
return _signature_from_builtin(Signature, obj,
|
||||
skip_bound_arg=skip_bound_arg)
|
||||
|
||||
if isfunction(obj) or _signature_is_functionlike(obj):
|
||||
# If it's a pure Python function, or an object that is duck type
|
||||
# of a Python function (Cython functions, for instance), then:
|
||||
return Signature.from_function(obj)
|
||||
|
||||
if _signature_is_builtin(obj):
|
||||
return _signature_from_builtin(Signature, obj,
|
||||
skip_bound_arg=skip_bound_arg)
|
||||
|
||||
if isinstance(obj, functools.partial):
|
||||
wrapped_sig = _signature_internal(obj.func,
|
||||
follow_wrapper_chains,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue