mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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:
parent
2488c1e1b6
commit
922a6cf6c2
2 changed files with 39 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue