summaryrefslogtreecommitdiffstats
path: root/Modules/itertoolsmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2015-07-28 09:07:14 (GMT)
committerRaymond Hettinger <python@rcn.com>2015-07-28 09:07:14 (GMT)
commitd2117e18a06a0e339f50a0a2c3c412710a45b77a (patch)
treebaf630b1d8ac5ec47e06a5a5bcd38a66a0681a4e /Modules/itertoolsmodule.c
parentde9fb28bf1a1d506916c34a5e4858807dc1f9575 (diff)
parentacd61b6e4092b316069a526930d8b3d43c1a14df (diff)
downloadcpython-d2117e18a06a0e339f50a0a2c3c412710a45b77a.zip
cpython-d2117e18a06a0e339f50a0a2c3c412710a45b77a.tar.gz
cpython-d2117e18a06a0e339f50a0a2c3c412710a45b77a.tar.bz2
merge
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r--Modules/itertoolsmodule.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index 0291b24..ac31e2f 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -2787,11 +2787,13 @@ cwr_next(cwrobject *co)
if (result == NULL)
goto empty;
co->result = result;
- elem = PyTuple_GET_ITEM(pool, 0);
- for (i=0; i<r ; i++) {
- assert(indices[i] == 0);
- Py_INCREF(elem);
- PyTuple_SET_ITEM(result, i, elem);
+ if (n > 0) {
+ elem = PyTuple_GET_ITEM(pool, 0);
+ for (i=0; i<r ; i++) {
+ assert(indices[i] == 0);
+ Py_INCREF(elem);
+ PyTuple_SET_ITEM(result, i, elem);
+ }
}
} else {
/* Copy the previous result tuple or re-use it if available */