diff options
author | Kristján Valur Jónsson <sweskman@gmail.com> | 2015-09-12 15:30:23 (GMT) |
---|---|---|
committer | Kristján Valur Jónsson <sweskman@gmail.com> | 2015-09-12 15:30:23 (GMT) |
commit | 95c3e6cb2243acc0a102d9fa59efece1427a3936 (patch) | |
tree | ec383c38241ed66bbb1bc17dbd1b68bcb3306a79 /Modules | |
parent | 0424eaf7533b0f386f6038dbb99f89e30fbbff76 (diff) | |
parent | 102764a1f6927955b9a907005ffd07216ebe1d96 (diff) | |
download | cpython-95c3e6cb2243acc0a102d9fa59efece1427a3936.zip cpython-95c3e6cb2243acc0a102d9fa59efece1427a3936.tar.gz cpython-95c3e6cb2243acc0a102d9fa59efece1427a3936.tar.bz2 |
Issue #25021: Merge from 3.3 to 3.4
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/itertoolsmodule.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index f5fa3fb..4693fbc 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -2236,13 +2236,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; } |