summaryrefslogtreecommitdiffstats
path: root/Modules/itertoolsmodule.c
diff options
context:
space:
mode:
authorKristján Valur Jónsson <sweskman@gmail.com>2015-09-12 16:36:15 (GMT)
committerKristján Valur Jónsson <sweskman@gmail.com>2015-09-12 16:36:15 (GMT)
commita8a930f86393cd037da4aab7906de0522fbce8dc (patch)
treebf70c29a34c53810adbf0ad874370f81412fe161 /Modules/itertoolsmodule.c
parent233cdb3e9c3d55a90763e9d5791b9e36f0a17882 (diff)
parentd7f65e5763fdf16afa0dc786bcc3e40024037aaf (diff)
downloadcpython-a8a930f86393cd037da4aab7906de0522fbce8dc.zip
cpython-a8a930f86393cd037da4aab7906de0522fbce8dc.tar.gz
cpython-a8a930f86393cd037da4aab7906de0522fbce8dc.tar.bz2
Issue #25021: Merge 3.5 to default
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r--Modules/itertoolsmodule.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index c7e1919..ff7867d 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -2256,13 +2256,21 @@ product_setstate(productobject *lz, PyObject *state)
{
PyObject* indexObject = PyTuple_GET_ITEM(state, i);
Py_ssize_t index = PyLong_AsSsize_t(indexObject);
+ PyObject* pool;
+ Py_ssize_t poolsize;
if (index < 0 && PyErr_Occurred())
return NULL; /* not an integer */
+ pool = PyTuple_GET_ITEM(lz->pools, i);
+ poolsize = PyTuple_GET_SIZE(pool);
+ if (poolsize == 0) {
+ lz->stopped = 1;
+ Py_RETURN_NONE;
+ }
/* clamp the index */
if (index < 0)
index = 0;
- else if (index > n-1)
- index = n-1;
+ else if (index > poolsize-1)
+ index = poolsize-1;
lz->indices[i] = index;
}