diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2022-12-05 18:27:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-05 17:27:40 +0100 |
| commit | 922a6cf6c265e2763a003291885ff74d46203fc3 (patch) | |
| tree | c9d0894817fe7e86f1b41e73ff35ce77b4c80fbc /Modules/itertoolsmodule.c | |
| parent | 2488c1e1b66366a3a933ff248eff080fabd2351c (diff) | |
| download | cpython-git-922a6cf6c265e2763a003291885ff74d46203fc3.tar.gz | |
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/itertoolsmodule.c')
| -rw-r--r-- | Modules/itertoolsmodule.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 7869d92bf3..d45000788c 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; } |
