diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-30 17:08:36 -0400 |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-30 17:08:36 -0400 |
commit | b9644c3e0c36a964387ff11bd4221879debe7ede (patch) | |
tree | ae70a428a2cf86f17574f082194617cde8f185e9 /Lib/inspect.py | |
parent | 4c72f0ac3e4fc363c1c7a4eca190af7b02861755 (diff) | |
download | cpython-b9644c3e0c36a964387ff11bd4221879debe7ede.tar.gz |
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.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 57cb3dc0ac..25ddd26c66 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__ |