8000 gh-123471: Make concurrent iteration over itertools.cycle safe under free-threading by eendebakpt · Pull Request #131212 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-123471: Make concurrent iteration over itertools.cycle safe under free-threading #131212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 2, 2025
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
0