mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #25718: Fixed pickling and copying the accumulate() iterator with total is None.
This commit is contained in:
parent
a01a144aab
commit
d55162517d
3 changed files with 30 additions and 0 deletions
|
@ -3460,6 +3460,23 @@ accumulate_next(accumulateobject *lz)
|
|||
static PyObject *
|
||||
accumulate_reduce(accumulateobject *lz)
|
||||
{
|
||||
if (lz->total == Py_None) {
|
||||
PyObject *it;
|
||||
|
||||
if (PyType_Ready(&chain_type) < 0)
|
||||
return NULL;
|
||||
if (PyType_Ready(&islice_type) < 0)
|
||||
return NULL;
|
||||
it = PyObject_CallFunction((PyObject *)&chain_type, "(O)O",
|
||||
lz->total, lz->it);
|
||||
if (it == NULL)
|
||||
return NULL;
|
||||
it = PyObject_CallFunction((PyObject *)Py_TYPE(lz), "NO",
|
||||
it, lz->binop ? lz->binop : Py_None);
|
||||
if (it == NULL)
|
||||
return NULL;
|
||||
return Py_BuildValue("O(NiO)", &islice_type, it, 1, Py_None);
|
||||
}
|
||||
return Py_BuildValue("O(OO)O", Py_TYPE(lz),
|
||||
lz->it, lz->binop?lz->binop:Py_None,
|
||||
lz->total?lz->total:Py_None);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue