@@ -4000,7 +4000,7 @@ listiter_setstate(PyObject *self, PyObject *state)
4000
4000
index = -1 ;
4001
4001
else if (index > PyList_GET_SIZE (it -> it_seq ))
4002
4002
index = PyList_GET_SIZE (it -> it_seq ); /* iterator exhausted */
4003
- it -> it_index = index ;
4003
+ FT_ATOMIC_STORE_SSIZE_RELAXED ( it -> it_index , index ) ;
4004
4004
}
4005
4005
Py_RETURN_NONE ;
4006
4006
}
@@ -4152,7 +4152,7 @@ listreviter_setstate(PyObject *self, PyObject *state)
4152
4152
index = -1 ;
4153
4153
else if (index > PyList_GET_SIZE (it -> it_seq ) - 1 )
4154
4154
index = PyList_GET_SIZE (it -> it_seq ) - 1 ;
4155
- it -> it_index = index ;
4155
+ FT_ATOMIC_STORE_SSIZE_RELAXED ( it -> it_index , index ) ;
4156
4156
}
4157
4157
Py_RETURN_NONE ;
4158
4158
}
@@ -4169,18 +4169,19 @@ listiter_reduce_general(void *_it, int forward)
4169
4169
* call must be before access of iterator pointers.
4170
4170
* see issue #101765 */
4171
4171
4172
- /* the objects are not the same, index is of different types! */
4173
4172
if (forward ) {
4174
4173
iter = _PyEval_GetBuiltin (& _Py_ID (iter ));
4175
4174
_PyListIterObject * it = (_PyListIterObject * )_it ;
4176
- if (it -> it_index >= 0 ) {
4177
- return Py_BuildValue ("N(O)n" , iter , it -> it_seq , it -> it_index );
4175
+ Py_ssize_t idx = FT_ATOMIC_LOAD_SSIZE_RELAXED (it -> it_index );
4176
+ if (idx >= 0 ) {
4177
+ return Py_BuildValue ("N(O)n" , iter , it -> it_seq , idx );
4178
4178
}
4179
4179
} else {
4180
4180
iter = _PyEval_GetBuiltin (& _Py_ID (reversed ));
4181
4181
listreviterobject * it = (listreviterobject * )_it ;
4182
- if (it -> it_index >= 0 ) {
4183
- return Py_BuildValue ("N(O)n" , iter , it -> it_seq , it -> it_index );
4182
+ Py_ssize_t idx = FT_ATOMIC_LOAD_SSIZE_RELAXED (it -> it_index );
4183
+ if (idx >= 0 ) {
4184
+ return Py_BuildValue ("N(O)n" , iter , it -> it_seq , idx );
4184
4185
}
4185
4186
}
4186
4187
/* empty iterator, create an empty list */
0 commit comments