mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
Issue #23934: Fix inspect.signature to fail correctly for builtin types.
Initial patch by James Powell.
This commit is contained in:
parent
dce09c34a0
commit
bf304fcb32
3 changed files with 14 additions and 2 deletions
|
|
@ -2255,9 +2255,13 @@ def _signature_from_callable(obj, *,
|
|||
if type not in obj.__mro__:
|
||||
# We have a class (not metaclass), but no user-defined
|
||||
# __init__ or __new__ for it
|
||||
if obj.__init__ is object.__init__:
|
||||
if (obj.__init__ is object.__init__ and
|
||||
obj.__new__ is object.__new__):
|
||||
# Return a signature of 'object' builtin.
|
||||
return signature(object)
|
||||
else:
|
||||
raise ValueError(
|
||||
'no signature found for builtin type {!r}'.format(obj))
|
||||
|
||||
elif not isinstance(obj, _NonUserDefinedCallables):
|
||||
# An object with __call__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue