We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a486d45 commit 8b19275Copy full SHA for 8b19275
Lib/test/test_code.py
@@ -1555,6 +1555,13 @@ def myfree(ptr):
1555
1556
FREE_FUNC = freefunc(myfree)
1557
FREE_INDEX = RequestCodeExtraIndex(FREE_FUNC)
1558
+ # Make sure myfree sticks around at least as long as the interpreter,
1559
+ # since we (currently) can't unregister the function and leaving a
1560
+ # dangling pointer will cause a crash on deallocation of code objects if
1561
+ # something else uses co_extras, like test_capi.test_misc. (Maybe this
1562
+ # should use PyInterpreterState_GetDict, but that isn't easily exposed
1563
+ # to Python code.)
1564
+ setattr(sys, f'_test_code.{myfree!r}', myfree)
1565
1566
class CoExtra(unittest.TestCase):
1567
def get_func(self):
0 commit comments