gh-129643: Fix PyList_Insert in free-threading builds (#129680)

This commit is contained in:
sobolevn 2025-02-06 15:54:40 +03:00 committed by GitHub
parent 779d06945c
commit 63f0406d5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View file

@ -0,0 +1 @@
Fix thread safety of :c:func:`PyList_Insert` in free-threading builds.

View file

@ -466,8 +466,8 @@ ins1(PyListObject *self, Py_ssize_t where, PyObject *v)
where = n; where = n;
items = self->ob_item; items = self->ob_item;
for (i = n; --i >= where; ) for (i = n; --i >= where; )
items[i+1] = items[i]; FT_ATOMIC_STORE_PTR_RELAXED(items[i+1], items[i]);
items[where] = Py_NewRef(v); FT_ATOMIC_STORE_PTR_RELEASE(items[where], Py_NewRef(v));
return 0; return 0;
} }