mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
inspect: Validate that __signature__ is None or an instance of Signature.
Closes #21801.
This commit is contained in:
parent
751c7c0f2d
commit
c0f964fd55
3 changed files with 13 additions and 0 deletions
|
@ -1912,6 +1912,10 @@ def _signature_internal(obj, follow_wrapper_chains=True, skip_bound_arg=True):
|
|||
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue