From dcb4d94921498a8a564f902cfa90cbb2b4128518 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Wed, 1 Mar 2023 15:57:26 +0900 Subject: [PATCH 1/2] gh-101101: Fix test_code_extra to reset value for refleak test --- 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..282aabcc40666b 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); - + // Need to reset 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); From 18cdc8aafff4041bf954957cf6dc1b0d68a9b434 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 2 Mar 2023 12:03:17 +0100 Subject: [PATCH 2/2] Update comment Co-authored-by: Erlend E. Aasland --- Modules/_testcapi/code.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_testcapi/code.c b/Modules/_testcapi/code.c index 282aabcc40666b..84c668cd6b3b00 100644 --- a/Modules/_testcapi/code.c +++ b/Modules/_testcapi/code.c @@ -92,7 +92,7 @@ test_code_extra(PyObject* self, PyObject *Py_UNUSED(callable)) goto finally; } assert ((uintptr_t)extra == 77); - // Need to reset code extra value. + // Revert to initial code extra value. res = PyUnstable_Code_SetExtra(test_func_code, code_extra_index, NULL); if (res < 0) { goto finally;