summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-05-30 21:08:36 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-05-30 21:08:36 (GMT)
commitbf304fcb3255d6fe52f83c120feccdf64f5a9715 (patch)
tree6bdb8df43c8e4bfc5a2fc2ef802daee0b24cdb2e /Lib/inspect.py
parentdce09c34a0a5d3ba5ddb2a948f3d0aa55ae3e9c4 (diff)
downloadcpython-bf304fcb3255d6fe52f83c120feccdf64f5a9715.zip
cpython-bf304fcb3255d6fe52f83c120feccdf64f5a9715.tar.gz
cpython-bf304fcb3255d6fe52f83c120feccdf64f5a9715.tar.bz2
Issue #23934: Fix inspect.signature to fail correctly for builtin types.
Initial patch by James Powell.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 57cb3dc..25ddd26 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -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__