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.
This commit is contained in:
Serhiy Storchaka 2022-12-05 18:27:40 +02:00 committed by GitHub
parent 2488c1e1b6
commit 922a6cf6c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 2 deletions

View file

@ -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;
}