Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Lib/test/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,13 @@ def myfree(ptr):

FREE_FUNC = freefunc(myfree)
FREE_INDEX = RequestCodeExtraIndex(FREE_FUNC)
# Make sure myfree sticks around at least as long as the interpreter,
# since we (currently) can't unregister the function and leaving a
# dangling pointer will cause a crash on deallocation of code objects if
# something else uses co_extras, like test_capi.test_misc. (Maybe this
# should use PyInterpreterState_GetDict, but that isn't easily exposed
# to Python code.)
setattr(sys, f'_test_code.{myfree!r}', myfree)
Comment thread
Yhg1s marked this conversation as resolved.
Outdated

class CoExtra(unittest.TestCase):
def get_func(self):
Expand Down
Loading