diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index c751184cf92..4bc9192abca 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -2713,20 +2713,20 @@ cwr_next(cwrobject *co) PyObject *result = co->result; Py_ssize_t n = PyTuple_GET_SIZE(pool); Py_ssize_t r = co->r; - Py_ssize_t i, j, index; + Py_ssize_t i, index; if (co->stopped) return NULL; if (result == NULL) { - /* On the first pass, initialize result tuple using the indices */ + /* On the first pass, initialize result tuple with pool[0] */ result = PyTuple_New(r); if (result == NULL) goto empty; co->result = result; + elem = PyTuple_GET_ITEM(pool, 0); for (i=0; i= 0 && indices[i] == n-1; i--) ; /* If i is negative, then the indices are all at - their maximum value and we're done. */ + their maximum value and we're done. */ if (i < 0) goto empty; /* Increment the current index which we know is not at its - maximum. Then set all to the right to the same value. */ - indices[i]++; - for (j=i+1 ; j