diff --git a/Modules/_testcapi/code.c b/Modules/_testcapi/code.c index 588dc67971ea5a..84c668cd6b3b00 100644 --- a/Modules/_testcapi/code.c +++ b/Modules/_testcapi/code.c @@ -92,7 +92,11 @@ test_code_extra(PyObject* self, PyObject *Py_UNUSED(callable)) goto finally; } assert ((uintptr_t)extra == 77); - + // Revert to initial code extra value. + res = PyUnstable_Code_SetExtra(test_func_code, code_extra_index, NULL); + if (res < 0) { + goto finally; + } result = Py_NewRef(Py_None); finally: Py_XDECREF(test_module);