From ed55c69ebd74178115cd8b080f7f8e7588cd5fda Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Thu, 2 Mar 2023 20:32:05 +0900 Subject: [PATCH] gh-101101: Fix test_code_extra to reset value for refleak test (gh-102350) --- Modules/_testcapi/code.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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);