diff -r a4101218364e Modules/_csv.c --- a/Modules/_csv.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Modules/_csv.c Mon Aug 15 10:52:59 2016 +0300 @@ -543,14 +543,10 @@ parse_save_field(ReaderObj *self) return -1; self->field_len = 0; if (self->numeric_field) { - PyObject *tmp; - self->numeric_field = 0; - tmp = PyNumber_Float(field); - Py_DECREF(field); - if (tmp == NULL) + Py_SETREF(field, PyNumber_Float(field)); + if (field == NULL) return -1; - field = tmp; } if (PyList_Append(self->fields, field) < 0) { Py_DECREF(field); diff -r a4101218364e Modules/_elementtree.c --- a/Modules/_elementtree.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Modules/_elementtree.c Mon Aug 15 10:52:59 2016 +0300 @@ -3468,7 +3468,6 @@ static PyObject * /* (internal) parse the whole input, until end of stream */ PyObject* reader; PyObject* buffer; - PyObject* temp; PyObject* res; reader = PyObject_GetAttrString(file, "read"); @@ -3492,14 +3491,13 @@ static PyObject * Py_DECREF(buffer); break; } - temp = PyUnicode_AsEncodedString(buffer, "utf-8", "surrogatepass"); - Py_DECREF(buffer); - if (!temp) { + Py_SETREF(buffer, + PyUnicode_AsEncodedString(buffer, "utf-8", "surrogatepass")); + if (!buffer) { /* Propagate exception from PyUnicode_AsEncodedString */ Py_DECREF(reader); return NULL; } - buffer = temp; } else if (!PyBytes_CheckExact(buffer) || PyBytes_GET_SIZE(buffer) == 0) { Py_DECREF(buffer); diff -r a4101218364e Modules/_io/stringio.c --- a/Modules/_io/stringio.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Modules/_io/stringio.c Mon Aug 15 10:52:59 2016 +0300 @@ -190,10 +190,8 @@ write_str(stringio *self, PyObject *obj) Py_INCREF(decoded); } if (self->writenl) { - PyObject *translated = PyUnicode_Replace( - decoded, _PyIO_str_nl, self->writenl, -1); - Py_DECREF(decoded); - decoded = translated; + Py_SETREF(decoded, + PyUnicode_Replace(decoded, _PyIO_str_nl, self->writenl, -1)); } if (decoded == NULL) return -1; diff -r a4101218364e Modules/_io/textio.c --- a/Modules/_io/textio.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Modules/_io/textio.c Mon Aug 15 10:52:59 2016 +0300 @@ -1302,12 +1302,10 @@ static PyObject * haslf = 1; if (haslf && self->writetranslate && self->writenl != NULL) { - PyObject *newtext = _PyObject_CallMethodId( - text, &PyId_replace, "ss", "\n", self->writenl); - Py_DECREF(text); - if (newtext == NULL) + Py_SETREF(text, _PyObject_CallMethodId( + text, &PyId_replace, "ss", "\n", self->writenl)); + if (text == NULL) return NULL; - text = newtext; } if (self->write_through) @@ -1869,11 +1867,9 @@ static PyObject * /* Our line ends in the current buffer */ self->decoded_chars_used = endpos - offset_to_buffer; if (start > 0 || endpos < PyUnicode_GET_LENGTH(line)) { - PyObject *s = PyUnicode_Substring(line, start, endpos); - Py_CLEAR(line); - if (s == NULL) + Py_SETREF(line, PyUnicode_Substring(line, start, endpos)); + if (line == NULL) goto error; - line = s; } } if (remaining != NULL) { diff -r a4101218364e Modules/_operator.c --- a/Modules/_operator.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Modules/_operator.c Mon Aug 15 10:52:59 2016 +0300 @@ -725,13 +725,10 @@ dotted_getattr(PyObject *obj, PyObject * Py_INCREF(obj); for (name_idx = 0; name_idx < name_count; ++name_idx) { attr_name = PyTuple_GET_ITEM(attr, name_idx); - newobj = PyObject_GetAttr(obj, attr_name); - Py_DECREF(obj); - if (newobj == NULL) { + Py_SETREF(obj, PyObject_GetAttr(obj, attr_name)); + if (obj == NULL) { return NULL; } - /* here */ - obj = newobj; } } else { /* single getattr */ newobj = PyObject_GetAttr(obj, attr); diff -r a4101218364e Modules/_testcapimodule.c --- a/Modules/_testcapimodule.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Modules/_testcapimodule.c Mon Aug 15 10:52:59 2016 +0300 @@ -440,7 +440,7 @@ test_longlong_api(PyObject* self, PyObje static PyObject * test_long_and_overflow(PyObject *self) { - PyObject *num, *one, *temp; + PyObject *num, *one; long value; int overflow; @@ -470,10 +470,9 @@ test_long_and_overflow(PyObject *self) Py_DECREF(num); return NULL; } - temp = PyNumber_Add(num, one); + + Py_SETREF(num, PyNumber_Add(num, one)); Py_DECREF(one); - Py_DECREF(num); - num = temp; if (num == NULL) return NULL; overflow = 0; @@ -514,10 +513,9 @@ test_long_and_overflow(PyObject *self) Py_DECREF(num); return NULL; } - temp = PyNumber_Subtract(num, one); + + Py_SETREF(num, PyNumber_Subtract(num, one)); Py_DECREF(one); - Py_DECREF(num); - num = temp; if (num == NULL) return NULL; overflow = 0; @@ -605,7 +603,7 @@ test_long_and_overflow(PyObject *self) static PyObject * test_long_long_and_overflow(PyObject *self) { - PyObject *num, *one, *temp; + PyObject *num, *one; PY_LONG_LONG value; int overflow; @@ -635,10 +633,9 @@ test_long_long_and_overflow(PyObject *se Py_DECREF(num); return NULL; } - temp = PyNumber_Add(num, one); + + Py_SETREF(num, PyNumber_Add(num, one)); Py_DECREF(one); - Py_DECREF(num); - num = temp; if (num == NULL) return NULL; overflow = 0; @@ -679,10 +676,9 @@ test_long_long_and_overflow(PyObject *se Py_DECREF(num); return NULL; } - temp = PyNumber_Subtract(num, one); + + Py_SETREF(num, PyNumber_Subtract(num, one)); Py_DECREF(one); - Py_DECREF(num); - num = temp; if (num == NULL) return NULL; overflow = 0; diff -r a4101218364e Modules/_tkinter.c --- a/Modules/_tkinter.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Modules/_tkinter.c Mon Aug 15 10:52:59 2016 +0300 @@ -1222,9 +1222,7 @@ fromBignumObj(PyObject* tkapp, Tcl_Obj * /* unsigned */ 0); PyMem_Free(bytes); if (res != NULL && bigValue.sign == MP_NEG) { - PyObject *res2 = PyNumber_Negative(res); - Py_DECREF(res); - res = res2; + Py_SETREF(res, PyNumber_Negative(res)); } mp_clear(&bigValue); return res; diff -r a4101218364e Modules/audioop.c --- a/Modules/audioop.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Modules/audioop.c Mon Aug 15 10:52:59 2016 +0300 @@ -1416,10 +1416,8 @@ audioop_ratecv_impl(PyObject *module, Py /* We have checked before that the length * of the string fits into int. */ len = (Py_ssize_t)(ncp - PyBytes_AsString(str)); - rv = PyBytes_FromStringAndSize - (PyBytes_AsString(str), len); - Py_DECREF(str); - str = rv; + Py_SETREF(str, + PyBytes_FromStringAndSize(PyBytes_AsString(str), len)); if (str == NULL) goto exit; rv = Py_BuildValue("(O(iO))", str, d, samps); diff -r a4101218364e Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Modules/itertoolsmodule.c Mon Aug 15 10:52:59 2016 +0300 @@ -1700,11 +1700,9 @@ starmap_next(starmapobject *lz) if (args == NULL) return NULL; if (!PyTuple_CheckExact(args)) { - PyObject *newargs = PySequence_Tuple(args); - Py_DECREF(args); - if (newargs == NULL) + Py_SETREF(args, PySequence_Tuple(args)); + if (args == NULL) return NULL; - args = newargs; } result = PyObject_Call(lz->func, args, NULL); Py_DECREF(args); diff -r a4101218364e Objects/capsule.c --- a/Objects/capsule.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Objects/capsule.c Mon Aug 15 10:52:59 2016 +0300 @@ -223,9 +223,7 @@ PyCapsule_Import(const char *name, int n } } } else { - PyObject *object2 = PyObject_GetAttrString(object, trace); - Py_DECREF(object); - object = object2; + Py_SETREF(object, PyObject_GetAttrString(object, trace)); } if (!object) { goto EXIT; diff -r a4101218364e Objects/fileobject.c --- a/Objects/fileobject.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Objects/fileobject.c Mon Aug 15 10:52:59 2016 +0300 @@ -97,10 +97,7 @@ PyFile_GetLine(PyObject *f, int n) if (result->ob_refcnt == 1) _PyBytes_Resize(&result, len-1); else { - PyObject *v; - v = PyBytes_FromStringAndSize(s, len-1); - Py_DECREF(result); - result = v; + Py_SETREF(result, PyBytes_FromStringAndSize(s, len - 1)); } } } @@ -113,10 +110,7 @@ PyFile_GetLine(PyObject *f, int n) "EOF when reading a line"); } else if (PyUnicode_READ_CHAR(result, len-1) == '\n') { - PyObject *v; - v = PyUnicode_Substring(result, 0, len-1); - Py_DECREF(result); - result = v; + Py_SETREF(result, PyUnicode_Substring(result, 0, len - 1)); } } return result; diff -r a4101218364e Objects/floatobject.c --- a/Objects/floatobject.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Objects/floatobject.c Mon Aug 15 10:52:59 2016 +0300 @@ -445,29 +445,21 @@ float_richcompare(PyObject *v, PyObject /* Shift left, and or a 1 bit into vv * to represent the lost fraction. */ - PyObject *temp; - one = PyLong_FromLong(1); if (one == NULL) goto Error; - temp = PyNumber_Lshift(ww, one); - if (temp == NULL) + Py_SETREF(ww, PyNumber_Lshift(ww, one)); + if (ww == NULL) goto Error; - Py_DECREF(ww); - ww = temp; - temp = PyNumber_Lshift(vv, one); - if (temp == NULL) + Py_SETREF(vv, PyNumber_Lshift(vv, one)); + if (vv == NULL) goto Error; - Py_DECREF(vv); - vv = temp; - temp = PyNumber_Or(vv, one); - if (temp == NULL) + Py_SETREF(vv, PyNumber_Or(vv, one)); + if (vv == NULL) goto Error; - Py_DECREF(vv); - vv = temp; } r = PyObject_RichCompareBool(vv, ww, op); diff -r a4101218364e Objects/longobject.c --- a/Objects/longobject.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Objects/longobject.c Mon Aug 15 10:52:59 2016 +0300 @@ -3611,26 +3611,24 @@ l_divmod(PyLongObject *v, PyLongObject * return -1; if ((Py_SIZE(mod) < 0 && Py_SIZE(w) > 0) || (Py_SIZE(mod) > 0 && Py_SIZE(w) < 0)) { - PyLongObject *temp; PyLongObject *one; - temp = (PyLongObject *) long_add(mod, w); - Py_DECREF(mod); - mod = temp; + Py_SETREF(mod, (PyLongObject *)long_add(mod, w)); if (mod == NULL) { Py_DECREF(div); return -1; } one = (PyLongObject *) PyLong_FromLong(1L); - if (one == NULL || - (temp = (PyLongObject *) long_sub(div, one)) == NULL) { + if (one == NULL) { Py_DECREF(mod); Py_DECREF(div); - Py_XDECREF(one); return -1; } + Py_SETREF(div, (PyLongObject *)long_sub(div, one)); Py_DECREF(one); - Py_DECREF(div); - div = temp; + if (div == NULL) { + Py_DECREF(mod); + return -1; + } } if (pdiv != NULL) *pdiv = div; @@ -3874,10 +3872,8 @@ long_true_divide(PyObject *v, PyObject * inexact = 1; } else { - PyLongObject *div, *rem; - div = x_divrem(x, b, &rem); - Py_DECREF(x); - x = div; + PyLongObject *rem; + Py_SETREF(x, x_divrem(x, b, &rem)); if (x == NULL) goto error; if (Py_SIZE(rem)) @@ -4833,7 +4829,7 @@ PyObject * _PyLong_DivmodNear(PyObject *a, PyObject *b) { PyLongObject *quo = NULL, *rem = NULL; - PyObject *one = NULL, *twice_rem, *result, *temp; + PyObject *one = NULL, *twice_rem, *result; int cmp, quo_is_odd, quo_is_neg; /* Equivalent Python code: @@ -4873,9 +4869,7 @@ PyObject * if (twice_rem == NULL) goto error; if (quo_is_neg) { - temp = long_neg((PyLongObject*)twice_rem); - Py_DECREF(twice_rem); - twice_rem = temp; + Py_SETREF(twice_rem, long_neg((PyLongObject *)twice_rem)); if (twice_rem == NULL) goto error; } @@ -4885,21 +4879,21 @@ PyObject * quo_is_odd = Py_SIZE(quo) != 0 && ((quo->ob_digit[0] & 1) != 0); if ((Py_SIZE(b) < 0 ? cmp < 0 : cmp > 0) || (cmp == 0 && quo_is_odd)) { /* fix up quotient */ - if (quo_is_neg) - temp = long_sub(quo, (PyLongObject *)one); - else - temp = long_add(quo, (PyLongObject *)one); - Py_DECREF(quo); - quo = (PyLongObject *)temp; + if (quo_is_neg) { + Py_SETREF(quo, (PyLongObject *)long_sub(quo, (PyLongObject *)one)); + } + else { + Py_SETREF(quo, (PyLongObject *)long_add(quo, (PyLongObject *)one)); + } if (quo == NULL) goto error; /* and remainder */ - if (quo_is_neg) - temp = long_add(rem, (PyLongObject *)b); - else - temp = long_sub(rem, (PyLongObject *)b); - Py_DECREF(rem); - rem = (PyLongObject *)temp; + if (quo_is_neg) { + Py_SETREF(rem, (PyLongObject *)long_add(rem, (PyLongObject *)b)); + } + else { + Py_SETREF(rem, (PyLongObject *)long_sub(rem, (PyLongObject *)b)); + } if (rem == NULL) goto error; } @@ -4924,7 +4918,7 @@ PyObject * static PyObject * long_round(PyObject *self, PyObject *args) { - PyObject *o_ndigits=NULL, *temp, *result, *ndigits; + PyObject *o_ndigits=NULL, *result, *ndigits; /* To round an integer m to the nearest 10**n (n positive), we make use of * the divmod_near operation, defined by: @@ -4956,9 +4950,7 @@ long_round(PyObject *self, PyObject *arg } /* result = self - divmod_near(self, 10 ** -ndigits)[1] */ - temp = long_neg((PyLongObject*)ndigits); - Py_DECREF(ndigits); - ndigits = temp; + Py_SETREF(ndigits, long_neg((PyLongObject *)ndigits)); if (ndigits == NULL) return NULL; @@ -4968,23 +4960,18 @@ long_round(PyObject *self, PyObject *arg return NULL; } - temp = long_pow(result, ndigits, Py_None); + + Py_SETREF(result, long_pow(result, ndigits, Py_None)); Py_DECREF(ndigits); - Py_DECREF(result); - result = temp; if (result == NULL) return NULL; - temp = _PyLong_DivmodNear(self, result); - Py_DECREF(result); - result = temp; + Py_SETREF(result, _PyLong_DivmodNear(self, result)); if (result == NULL) return NULL; - temp = long_sub((PyLongObject *)self, - (PyLongObject *)PyTuple_GET_ITEM(result, 1)); - Py_DECREF(result); - result = temp; + Py_SETREF(result, + long_sub((PyLongObject *)self, (PyLongObject *)PyTuple_GET_ITEM(result, 1))); return result; } diff -r a4101218364e Objects/setobject.c --- a/Objects/setobject.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Objects/setobject.c Mon Aug 15 10:52:59 2016 +0300 @@ -577,7 +577,7 @@ set_dealloc(PySetObject *so) static PyObject * set_repr(PySetObject *so) { - PyObject *result=NULL, *keys, *listrepr, *tmp; + PyObject *result=NULL, *keys, *listrepr; int status = Py_ReprEnter((PyObject*)so); if (status != 0) { @@ -601,11 +601,10 @@ set_repr(PySetObject *so) Py_DECREF(keys); if (listrepr == NULL) goto done; - tmp = PyUnicode_Substring(listrepr, 1, PyUnicode_GET_LENGTH(listrepr)-1); - Py_DECREF(listrepr); - if (tmp == NULL) + Py_SETREF(listrepr, PyUnicode_Substring(listrepr, 1, + PyUnicode_GET_LENGTH(listrepr) - 1)); + if (listrepr == NULL) goto done; - listrepr = tmp; if (Py_TYPE(so) != &PySet_Type) result = PyUnicode_FromFormat("%s({%U})", diff -r a4101218364e Objects/sliceobject.c --- a/Objects/sliceobject.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Objects/sliceobject.c Mon Aug 15 10:52:59 2016 +0300 @@ -394,9 +394,7 @@ int if (_PyLong_Sign(start) < 0) { /* start += length */ - PyObject *tmp = PyNumber_Add(start, length); - Py_DECREF(start); - start = tmp; + Py_SETREF(start, PyNumber_Add(start, length)); if (start == NULL) goto error; @@ -433,9 +431,7 @@ int if (_PyLong_Sign(stop) < 0) { /* stop += length */ - PyObject *tmp = PyNumber_Add(stop, length); - Py_DECREF(stop); - stop = tmp; + Py_SETREF(stop, PyNumber_Add(stop, length)); if (stop == NULL) goto error; diff -r a4101218364e Objects/typeobject.c --- a/Objects/typeobject.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Objects/typeobject.c Mon Aug 15 10:52:59 2016 +0300 @@ -4418,9 +4418,7 @@ object_dir(PyObject *self, PyObject *arg } else { /* Copy __dict__ to avoid mutating it. */ - PyObject *temp = PyDict_Copy(dict); - Py_DECREF(dict); - dict = temp; + Py_SETREF(dict, PyDict_Copy(dict)); } if (dict == NULL) @@ -7227,13 +7225,11 @@ super_getattro(PyObject *self, PyObject f = Py_TYPE(res)->tp_descr_get; if (f != NULL) { - tmp = f(res, + Py_SETREF(res, f(res, /* Only pass 'obj' param if this is instance-mode super (See SF ID #743627) */ (su->obj == (PyObject *)starttype) ? NULL : su->obj, - (PyObject *)starttype); - Py_DECREF(res); - res = tmp; + (PyObject *)starttype)); } Py_DECREF(mro); diff -r a4101218364e Objects/unicodeobject.c --- a/Objects/unicodeobject.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Objects/unicodeobject.c Mon Aug 15 10:52:59 2016 +0300 @@ -14031,10 +14031,7 @@ PyObject * } if (!PyUnicode_Check(result) || buf != PyUnicode_DATA(result)) { - PyObject *unicode; - unicode = _PyUnicode_FromASCII(buf, len); - Py_DECREF(result); - result = unicode; + Py_SETREF(result, _PyUnicode_FromASCII(buf, len)); } else if (len != PyUnicode_GET_LENGTH(result)) { if (PyUnicode_Resize(&result, len) < 0) diff -r a4101218364e Python/ast.c --- a/Python/ast.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Python/ast.c Mon Aug 15 10:52:59 2016 +0300 @@ -632,17 +632,14 @@ new_identifier(const char *n, struct com /* Check whether there are non-ASCII characters in the identifier; if so, normalize to NFKC. */ if (!PyUnicode_IS_ASCII(id)) { - PyObject *id2; if (!c->c_normalize && !init_normalization(c)) { Py_DECREF(id); return NULL; } PyTuple_SET_ITEM(c->c_normalize_args, 1, id); - id2 = PyObject_Call(c->c_normalize, c->c_normalize_args, NULL); - Py_DECREF(id); - if (!id2) + Py_SETREF(id, PyObject_Call(c->c_normalize, c->c_normalize_args, NULL)); + if (!id) return NULL; - id = id2; } PyUnicode_InternInPlace(&id); if (PyArena_AddPyObject(c->c_arena, id) < 0) { @@ -3105,34 +3102,31 @@ alias_for_import_name(struct compiling * int i; size_t len; char *s; - PyObject *uni; + PyObject *bytes; len = 0; for (i = 0; i < NCH(n); i += 2) /* length of string plus one for the dot */ len += strlen(STR(CHILD(n, i))) + 1; len--; /* the last name doesn't have a dot */ - str = PyBytes_FromStringAndSize(NULL, len); - if (!str) + bytes = PyBytes_FromStringAndSize(NULL, len); + if (!bytes) return NULL; - s = PyBytes_AS_STRING(str); - if (!s) - return NULL; + s = PyBytes_AS_STRING(bytes); for (i = 0; i < NCH(n); i += 2) { - char *sch = STR(CHILD(n, i)); - strcpy(s, STR(CHILD(n, i))); + const char *sch = STR(CHILD(n, i)); + strcpy(s, sch); s += strlen(sch); *s++ = '.'; } --s; *s = '\0'; - uni = PyUnicode_DecodeUTF8(PyBytes_AS_STRING(str), - PyBytes_GET_SIZE(str), + str = PyUnicode_DecodeUTF8(PyBytes_AS_STRING(bytes), + PyBytes_GET_SIZE(bytes), NULL); - Py_DECREF(str); - if (!uni) + Py_DECREF(bytes); + if (!str) return NULL; - str = uni; PyUnicode_InternInPlace(&str); if (PyArena_AddPyObject(c->c_arena, str) < 0) { Py_DECREF(str); diff -r a4101218364e Python/bltinmodule.c --- a/Python/bltinmodule.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Python/bltinmodule.c Mon Aug 15 10:52:59 2016 +0300 @@ -2178,7 +2178,7 @@ builtin_sum_impl(PyObject *module, PyObj /*[clinic end generated code: output=df758cec7d1d302f input=3b5b7a9d7611c73a]*/ { PyObject *result = start; - PyObject *temp, *item, *iter; + PyObject *item, *iter; iter = PyObject_GetIter(iterable); if (iter == NULL) @@ -2250,10 +2250,8 @@ builtin_sum_impl(PyObject *module, PyObj Py_DECREF(iter); return NULL; } - temp = PyNumber_Add(result, item); - Py_DECREF(result); + Py_SETREF(result, PyNumber_Add(result, item)); Py_DECREF(item); - result = temp; if (result == NULL) { Py_DECREF(iter); return NULL; @@ -2293,10 +2291,8 @@ builtin_sum_impl(PyObject *module, PyObj } } result = PyFloat_FromDouble(f_result); - temp = PyNumber_Add(result, item); - Py_DECREF(result); + Py_SETREF(result, PyNumber_Add(result, item)); Py_DECREF(item); - result = temp; if (result == NULL) { Py_DECREF(iter); return NULL; @@ -2324,10 +2320,8 @@ builtin_sum_impl(PyObject *module, PyObj sum([[x] for x in range(10)], empty) would change the value of empty. */ - temp = PyNumber_Add(result, item); - Py_DECREF(result); + Py_SETREF(result, PyNumber_Add(result, item)); Py_DECREF(item); - result = temp; if (result == NULL) break; } diff -r a4101218364e Python/sysmodule.c --- a/Python/sysmodule.c Mon Aug 15 10:06:16 2016 +0300 +++ b/Python/sysmodule.c Mon Aug 15 10:52:59 2016 +0300 @@ -1308,9 +1308,7 @@ list_builtin_module_names(void) list = NULL; } if (list) { - PyObject *v = PyList_AsTuple(list); - Py_DECREF(list); - list = v; + Py_SETREF(list, PyList_AsTuple(list)); } return list; }