We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f9d0531 commit bc30930Copy full SHA for bc30930
Modules/itertoolsmodule.c
@@ -3630,10 +3630,13 @@ static PyObject *
3630
repeat_next(PyObject *op)
3631
{
3632
repeatobject *ro = repeatobject_CAST(op);
3633
- if (ro->cnt == 0)
+ Py_ssize_t cnt = FT_ATOMIC_LOAD_SSIZE_RELAXED(ro->cnt);
3634
+ if (cnt == 0) {
3635
return NULL;
- if (ro->cnt > 0)
3636
- ro->cnt--;
+ }
3637
+ cnt--;
3638
+ assert(cnt >=0);
3639
+ FT_ATOMIC_STORE_SSIZE_RELAXED(ro->cnt, cnt);
3640
return Py_NewRef(ro->element);
3641
}
3642
0 commit comments