Skip to content

Commit e7e439b

Browse files
committed
gh-158592: Reallocate the list's array when deleting by index
1 parent 5c7445b commit e7e439b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎Objects/listobject.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ list_ass_item_lock_held(PyListObject *a, Py_ssize_t i, PyObject *v)
11481148
for (Py_ssize_t idx = i; idx < size - 1; idx++) {
11491149
FT_ATOMIC_STORE_PTR_RELEASE(a->ob_item[idx], a->ob_item[idx + 1]);
11501150
}
1151-
Py_SET_SIZE(a, size - 1);
1151+
list_resize(a, size - 1); // NB: shrinking a list can't fail
11521152
}
11531153
else {
11541154
FT_ATOMIC_STORE_PTR_RELEASE(a->ob_item[i], Py_NewRef(v));

0 commit comments

Comments
 (0)