Skip to content
Prev Previous commit
Next Next commit
use explicit lock
  • Loading branch information
eendebakpt committed Jun 1, 2025
commit baec5bce294d5b8ce2cf1b4ede0e2ac58bbd5567
5 changes: 2 additions & 3 deletions Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,9 +809,8 @@ iter_locked_next(PyObject *op)
// we cannot use Py_BEGIN_CRITICAL_SECTION as it is not available in the normal build
PyMutex_Lock(&(lz->lock));

PyObject *it = lz->it;
result = PyIter_Next(it);
if (result == NULL) {
int v = PyIter_NextItem(lz->it, &result);
if (v == -1) {
/* Note: StopIteration is already cleared by PyIter_Next() */
/* If PyErr_Occurred() we will also return NULL*/
}
Expand Down