Skip to content

Commit 976dec9

Browse files
authored
bpo-46417: _PyList_Fini() clears indexerr (GH-30815)
_PyList_Fini() now clears the 'indexerr' error message.
1 parent bcacab4 commit 976dec9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Objects/listobject.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class list "PyListObject *" "&PyList_Type"
1515

1616
#include "clinic/listobject.c.h"
1717

18+
static PyObject *indexerr = NULL;
19+
1820
#if PyList_MAXFREELIST > 0
1921
static struct _Py_list_state *
2022
get_list_state(void)
@@ -123,6 +125,10 @@ _PyList_Fini(PyInterpreterState *interp)
123125
struct _Py_list_state *state = &interp->list;
124126
state->numfree = -1;
125127
#endif
128+
129+
if (_Py_IsMainInterpreter(interp)) {
130+
Py_CLEAR(indexerr);
131+
}
126132
}
127133

128134
/* Print summary info about the state of the optimized allocator */
@@ -224,8 +230,6 @@ valid_index(Py_ssize_t i, Py_ssize_t limit)
224230
return (size_t) i < (size_t) limit;
225231
}
226232

227-
static PyObject *indexerr = NULL;
228-
229233
PyObject *
230234
PyList_GetItem(PyObject *op, Py_ssize_t i)
231235
{

0 commit comments

Comments
 (0)