File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 1+ Make concurrent iteration over :class: `itertools.dropwhile ` and
2+ :class: `itertools.takewhile ` safe under free-threading.
Original file line number Diff line number Diff line change @@ -1340,7 +1340,7 @@ dropwhile_next(PyObject *op)
13401340 item = iternext (it );
13411341 if (item == NULL )
13421342 return NULL ;
1343- if (lz -> start == 1 )
1343+ if (FT_ATOMIC_LOAD_LONG_RELAXED ( lz -> start ) == 1 )
13441344 return item ;
13451345
13461346 good = PyObject_CallOneArg (lz -> func , item );
@@ -1351,7 +1351,7 @@ dropwhile_next(PyObject *op)
13511351 ok = PyObject_IsTrue (good );
13521352 Py_DECREF (good );
13531353 if (ok == 0 ) {
1354- lz -> start = 1 ;
1354+ FT_ATOMIC_STORE_LONG_RELAXED ( lz -> start , 1 ) ;
13551355 return item ;
13561356 }
13571357 Py_DECREF (item );
@@ -1457,7 +1457,7 @@ takewhile_next(PyObject *op)
14571457 PyObject * it = lz -> it ;
14581458 long ok ;
14591459
1460- if (lz -> stop == 1 )
1460+ if (FT_ATOMIC_LOAD_LONG_RELAXED ( lz -> stop ) == 1 )
14611461 return NULL ;
14621462
14631463 item = (* Py_TYPE (it )-> tp_iternext )(it );
@@ -1475,7 +1475,7 @@ takewhile_next(PyObject *op)
14751475 return item ;
14761476 Py_DECREF (item );
14771477 if (ok == 0 )
1478- lz -> stop = 1 ;
1478+ FT_ATOMIC_STORE_LONG_RELAXED ( lz -> stop , 1 ) ;
14791479 return NULL ;
14801480}
14811481
You can’t perform that action at this time.
0 commit comments