diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-27 10:38:28 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-27 10:38:28 (GMT) |
commit | bdb908ea5466bfa09869fd2e1e7f3b17fe0fb2ea (patch) | |
tree | ab1e4e4a74bd5cb976d2473b5e76e9ba74b94edb /Modules/itertoolsmodule.c | |
parent | 40005a7807bf2140d045c2bb8b4ef8af1e4770a0 (diff) | |
parent | 4a1e70fc31d224786a32f950edaf73c8ea9c194d (diff) | |
download | cpython-bdb908ea5466bfa09869fd2e1e7f3b17fe0fb2ea.zip cpython-bdb908ea5466bfa09869fd2e1e7f3b17fe0fb2ea.tar.gz cpython-bdb908ea5466bfa09869fd2e1e7f3b17fe0fb2ea.tar.bz2 |
Issue #20440: Applied yet one patch for using Py_SETREF.
The patch is automatically generated, it replaces the code that uses Py_CLEAR.
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r-- | Modules/itertoolsmodule.c | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 29c62e7..2bd0594 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -158,15 +158,12 @@ groupby_setstate(groupbyobject *lz, PyObject *state) PyObject *currkey, *currvalue, *tgtkey; if (!PyArg_ParseTuple(state, "OOO", &currkey, &currvalue, &tgtkey)) return NULL; - Py_CLEAR(lz->currkey); - lz->currkey = currkey; - Py_INCREF(lz->currkey); - Py_CLEAR(lz->currvalue); - lz->currvalue = currvalue; - Py_INCREF(lz->currvalue); - Py_CLEAR(lz->tgtkey); - lz->tgtkey = tgtkey; - Py_INCREF(lz->tgtkey); + Py_INCREF(currkey); + Py_SETREF(lz->currkey, currkey); + Py_INCREF(currvalue); + Py_SETREF(lz->currvalue, currvalue); + Py_INCREF(tgtkey); + Py_SETREF(lz->tgtkey, tgtkey); Py_RETURN_NONE; } @@ -745,9 +742,8 @@ tee_setstate(teeobject *to, PyObject *state) PyErr_SetString(PyExc_ValueError, "Index out of range"); return NULL; } - Py_CLEAR(to->dataobj); - to->dataobj = tdo; - Py_INCREF(to->dataobj); + Py_INCREF(tdo); + Py_SETREF(to->dataobj, tdo); to->index = index; Py_RETURN_NONE; } @@ -988,8 +984,7 @@ cycle_setstate(cycleobject *lz, PyObject *state) if (!PyArg_ParseTuple(state, "O!i", &PyList_Type, &saved, &firstpass)) return NULL; Py_INCREF(saved); - Py_CLEAR(lz->saved); - lz->saved = saved; + Py_SETREF(lz->saved, saved); lz->firstpass = firstpass != 0; lz->index = 0; Py_RETURN_NONE; @@ -1920,12 +1915,10 @@ chain_setstate(chainobject *lz, PyObject *state) if (! PyArg_ParseTuple(state, "O|O", &source, &active)) return NULL; - Py_CLEAR(lz->source); - lz->source = source; - Py_INCREF(lz->source); - Py_CLEAR(lz->active); - lz->active = active; - Py_XINCREF(lz->active); + Py_INCREF(source); + Py_SETREF(lz->source, source); + Py_XINCREF(active); + Py_SETREF(lz->active, active); Py_RETURN_NONE; } @@ -2282,8 +2275,7 @@ product_setstate(productobject *lz, PyObject *state) Py_INCREF(element); PyTuple_SET_ITEM(result, i, element); } - Py_CLEAR(lz->result); - lz->result = result; + Py_SETREF(lz->result, result); Py_RETURN_NONE; } @@ -2604,8 +2596,7 @@ combinations_setstate(combinationsobject *lz, PyObject *state) PyTuple_SET_ITEM(result, i, element); } - Py_CLEAR(lz->result); - lz->result = result; + Py_SETREF(lz->result, result); Py_RETURN_NONE; } @@ -2935,8 +2926,7 @@ cwr_setstate(cwrobject *lz, PyObject *state) Py_INCREF(element); PyTuple_SET_ITEM(result, i, element); } - Py_CLEAR(lz->result); - lz->result = result; + Py_SETREF(lz->result, result); Py_RETURN_NONE; } @@ -3324,8 +3314,7 @@ permutations_setstate(permutationsobject *po, PyObject *state) Py_INCREF(element); PyTuple_SET_ITEM(result, i, element); } - Py_CLEAR(po->result); - po->result = result; + Py_SETREF(po->result, result); Py_RETURN_NONE; } @@ -3495,9 +3484,8 @@ accumulate_reduce(accumulateobject *lz) static PyObject * accumulate_setstate(accumulateobject *lz, PyObject *state) { - Py_CLEAR(lz->total); - lz->total = state; - Py_INCREF(lz->total); + Py_INCREF(state); + Py_SETREF(lz->total, state); Py_RETURN_NONE; } @@ -4475,9 +4463,8 @@ zip_longest_reduce(ziplongestobject *lz) static PyObject * zip_longest_setstate(ziplongestobject *lz, PyObject *state) { - Py_CLEAR(lz->fillvalue); - lz->fillvalue = state; - Py_INCREF(lz->fillvalue); + Py_INCREF(state); + Py_SETREF(lz->fillvalue, state); Py_RETURN_NONE; } |