Fix crash in itertools.cycle.__setstate__() caused by lack of type checking.

Will backport after the 3.6 release is done.
This commit is contained in:
Raymond Hettinger 2015-08-15 13:51:59 -07:00
parent b468e1f595
commit 79c878d5f2
3 changed files with 37 additions and 1 deletions

View file

@ -973,7 +973,7 @@ cycle_setstate(cycleobject *lz, PyObject *state)
{
PyObject *saved=NULL;
int firstpass;
if (!PyArg_ParseTuple(state, "Oi", &saved, &firstpass))
if (!PyArg_ParseTuple(state, "O!i", &PyList_Type, &saved, &firstpass))
return NULL;
Py_CLEAR(lz->saved);
lz->saved = saved;