GH-88116: Document that PyCodeNew is dangerous, and make PyCode_NewEmpty less dangerous. (GH-91790)

This commit is contained in:
Mark Shannon 2022-04-21 19:08:36 +01:00 committed by GitHub
parent 5974827c71
commit d44815cabc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 7 deletions

View file

@ -176,6 +176,9 @@ class CodeTest(unittest.TestCase):
self.assertEqual(co.co_filename, "filename")
self.assertEqual(co.co_name, "funcname")
self.assertEqual(co.co_firstlineno, 15)
#Empty code object should raise, but not crash the VM
with self.assertRaises(Exception):
exec(co)
@cpython_only
def test_closure_injection(self):