]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46417: _PyList_Fini() clears indexerr (GH-30815)
authorVictor Stinner <vstinner@python.org>
Sun, 23 Jan 2022 01:20:44 +0000 (02:20 +0100)
committerGitHub <noreply@github.com>
Sun, 23 Jan 2022 01:20:44 +0000 (02:20 +0100)
_PyList_Fini() now clears the 'indexerr' error message.

Objects/listobject.c

index 0ce58b240327f93df73709df16d633ae0fd6968c..752d9e00bb7bfc460532fe2d016485ced2cc7d5d 100644 (file)
@@ -15,6 +15,8 @@ class list "PyListObject *" "&PyList_Type"
 
 #include "clinic/listobject.c.h"
 
+static PyObject *indexerr = NULL;
+
 #if PyList_MAXFREELIST > 0
 static struct _Py_list_state *
 get_list_state(void)
@@ -123,6 +125,10 @@ _PyList_Fini(PyInterpreterState *interp)
     struct _Py_list_state *state = &interp->list;
     state->numfree = -1;
 #endif
+
+    if (_Py_IsMainInterpreter(interp)) {
+        Py_CLEAR(indexerr);
+    }
 }
 
 /* Print summary info about the state of the optimized allocator */
@@ -224,8 +230,6 @@ valid_index(Py_ssize_t i, Py_ssize_t limit)
     return (size_t) i < (size_t) limit;
 }
 
-static PyObject *indexerr = NULL;
-
 PyObject *
 PyList_GetItem(PyObject *op, Py_ssize_t i)
 {