summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-12-05 16:27:40 (GMT)
committerGitHub <noreply@github.com>2022-12-05 16:27:40 (GMT)
commit922a6cf6c265e2763a003291885ff74d46203fc3 (patch)
treec9d0894817fe7e86f1b41e73ff35ce77b4c80fbc /Modules
parent2488c1e1b66366a3a933ff248eff080fabd2351c (diff)
downloadcpython-922a6cf6c265e2763a003291885ff74d46203fc3.zip
cpython-922a6cf6c265e2763a003291885ff74d46203fc3.tar.gz
cpython-922a6cf6c265e2763a003291885ff74d46203fc3.tar.bz2
gh-60203: Revert changes in cycle.__setstate__ (#99982)
In case if only True/False be supported as boolean arguments in future, we should continue to support 1/0 here.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/itertoolsmodule.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index 7869d92..d450007 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -1368,12 +1368,13 @@ cycle_setstate(cycleobject *lz, PyObject *state)
PyErr_SetString(PyExc_TypeError, "state is not a tuple");
return NULL;
}
- if (!PyArg_ParseTuple(state, "O!p", &PyList_Type, &saved, &firstpass)) {
+ // The second item can be 1/0 in old pickles and True/False in new pickles
+ if (!PyArg_ParseTuple(state, "O!i", &PyList_Type, &saved, &firstpass)) {
return NULL;
}
Py_INCREF(saved);
Py_XSETREF(lz->saved, saved);
- lz->firstpass = firstpass;
+ lz->firstpass = firstpass != 0;
lz->index = 0;
Py_RETURN_NONE;
}