Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix thread safety of :c:func:`PyList_Insert` in free-threading builds.
6 changes: 2 additions & 4 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ static int
ins1(PyListObject *self, Py_ssize_t where, PyObject *v)
{
Py_ssize_t i, n = Py_SIZE(self);
PyObject **items;
if (v == NULL) {
PyErr_BadInternalCall();
return -1;
Expand All @@ -464,10 +463,9 @@ ins1(PyListObject *self, Py_ssize_t where, PyObject *v)
}
if (where > n)
where = n;
items = self->ob_item;
for (i = n; --i >= where; )
items[i+1] = items[i];
items[where] = Py_NewRef(v);
FT_ATOMIC_STORE_PTR_RELEASE(self->ob_item[i+1], self->ob_item[i]);
Comment thread
sobolevn marked this conversation as resolved.
Outdated
FT_ATOMIC_STORE_PTR_RELEASE(self->ob_item[where], Py_NewRef(v));
Comment thread
sobolevn marked this conversation as resolved.
Outdated
return 0;
}

Expand Down