inspect: Validate that __signature__ is None or an instance of Signature.

Closes #21801.
This commit is contained in:
Yury Selivanov 2014-06-23 10:23:50 -07:00
parent 289cae4f92
commit 42407abe24
3 changed files with 14 additions and 0 deletions

View file

@ -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: