mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
SF bug #793826: using itertools.izip to mutate tuples
Avoid Armin Rigo's dastardly exercise in re-entrancy.
This commit is contained in:
parent
b738041c5d
commit
a56f6b6600
2 changed files with 36 additions and 3 deletions
|
@ -1595,16 +1595,18 @@ izip_next(izipobject *lz)
|
|||
if (tuplesize == 0)
|
||||
return NULL;
|
||||
if (result->ob_refcnt == 1) {
|
||||
Py_INCREF(result);
|
||||
for (i=0 ; i < tuplesize ; i++) {
|
||||
it = PyTuple_GET_ITEM(lz->ittuple, i);
|
||||
assert(PyIter_Check(it));
|
||||
item = (*it->ob_type->tp_iternext)(it);
|
||||
if (item == NULL)
|
||||
if (item == NULL) {
|
||||
Py_DECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(PyTuple_GET_ITEM(result, i));
|
||||
PyTuple_SET_ITEM(result, i, item);
|
||||
}
|
||||
Py_INCREF(result);
|
||||
} else {
|
||||
result = PyTuple_New(tuplesize);
|
||||
if (result == NULL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue