summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2014-06-23 17:23:50 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2014-06-23 17:23:50 (GMT)
commit42407abe2450819b74b9ccb1fbe99edc78bbbb41 (patch)
tree4ebda4c6d2a697ab25969063485329f50cc60b3a /Lib/inspect.py
parent289cae4f929997bcfe9689c3e9dd7a3be5e5919f (diff)
downloadcpython-42407abe2450819b74b9ccb1fbe99edc78bbbb41.zip
cpython-42407abe2450819b74b9ccb1fbe99edc78bbbb41.tar.gz
cpython-42407abe2450819b74b9ccb1fbe99edc78bbbb41.tar.bz2
inspect: Validate that __signature__ is None or an instance of Signature.
Closes #21801.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 4ac76b1..b9cdcc2 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -1939,6 +1939,10 @@ def _signature_from_callable(obj, *,
pass
else:
if sig is not None:
+ if not isinstance(sig, Signature):
+ raise TypeError(
+ 'unexpected object {!r} in __signature__ '
+ 'attribute'.format(sig))
return sig
try: