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:
self.assertEqual(lines[:-1], inspect.getsource(module).splitlines())
self.assertEqual(err, b'')
+ def test_custom_getattr(self):
+ def foo():
+ pass
+ foo.__signature__ = 42
+ with self.assertRaises(TypeError):
+ inspect.signature(foo)
+
@unittest.skipIf(ThreadPoolExecutor is None,
'threads required to test __qualname__ for source files')
def test_qualname_source(self):
- Issue #21538: The plistlib module now supports loading of binary plist files
when reference or offset size is not a power of two.
+- Issue #21801: Validate that __signature__ is None or an instance of Signature.
+
Build
-----