Skip to content
Prev Previous commit
Next Next commit
use PyList_GetItemRef
  • Loading branch information
eendebakpt committed May 28, 2025
commit ab442da8ecac1dc16812c1f1425d5dfce36bcf24
5 changes: 3 additions & 2 deletions Modules/itertoolsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,13 +1219,14 @@ cycle_next(PyObject *op)
}
if (PyList_GET_SIZE(lz->saved) == 0)
return NULL;
item = PyList_GET_ITEM(lz->saved, index);
item = PyList_GetItemRef(lz->saved, index);
assert(item);
index++;
if (index >= PyList_GET_SIZE(lz->saved)) {
index = 0;
}
FT_ATOMIC_STORE_SSIZE_RELAXED(lz->index, index);
return Py_NewRef(item);
return item;
}

static PyType_Slot cycle_slots[] = {
Expand Down
Loading