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 11e727d commit 931b2f9Copy full SHA for 931b2f9
Modules/itertoolsmodule.c
@@ -366,7 +366,7 @@ pairwise_next_lock_held(PyObject *op)
366
return NULL;
367
}
368
369
- Py_INCREF(old);
+ Py_INCREF(old); // needed because of reentant calls via call to the iterator
370
new = (*Py_TYPE(it)->tp_iternext)(it);
371
if (new == NULL) {
372
Py_CLEAR(po->it);
@@ -380,7 +380,7 @@ pairwise_next_lock_held(PyObject *op)
380
Py_INCREF(result);
381
PyObject *last_old = PyTuple_GET_ITEM(result, 0);
382
PyObject *last_new = PyTuple_GET_ITEM(result, 1);
383
- PyTuple_SET_ITEM(result, 0, old);
+ PyTuple_SET_ITEM(result, 0, old); // consume the reference from old
384
PyTuple_SET_ITEM(result, 1, Py_NewRef(new));
385
Py_DECREF(last_old);
386
Py_DECREF(last_new);
0 commit comments