diff -r 06772ba3d001 Mac/Modules/_scproxy.c --- a/Mac/Modules/_scproxy.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Mac/Modules/_scproxy.c Fri Nov 09 01:59:49 2012 +0100 @@ -79,7 +79,7 @@ get_proxy_settings(PyObject* mod __attri if (v == NULL) goto error; r = PyDict_SetItemString(result, "exclude_simple", v); - Py_DECREF(v); v = NULL; + Py_CLEAR(v); if (r == -1) goto error; anArray = CFDictionaryGetValue(proxyDict, diff -r 06772ba3d001 Mac/Modules/carbonevt/_CarbonEvtmodule.c --- a/Mac/Modules/carbonevt/_CarbonEvtmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Mac/Modules/carbonevt/_CarbonEvtmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -1051,8 +1051,7 @@ static PyObject *EventHandlerRef_RemoveE _err = RemoveEventHandler(_self->ob_itself); if (_err != noErr) return PyMac_Error(_err); _self->ob_itself = NULL; - Py_DECREF(_self->ob_callback); - _self->ob_callback = NULL; + Py_CLEAR(_self->ob_callback); Py_INCREF(Py_None); _res = Py_None; return _res; diff -r 06772ba3d001 Mac/Modules/list/_Listmodule.c --- a/Mac/Modules/list/_Listmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Mac/Modules/list/_Listmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -76,8 +76,7 @@ int ListObj_Convert(PyObject *v, ListHan static void ListObj_dealloc(ListObject *self) { - Py_XDECREF(self->ob_ldef_func); - self->ob_ldef_func = NULL; + Py_CLEAR(self->ob_ldef_func); SetListRefCon(self->ob_itself, (long)0); if (self->ob_must_be_disposed && self->ob_itself) LDispose(self->ob_itself); self->ob_type->tp_free((PyObject *)self); diff -r 06772ba3d001 Modules/_bsddb.c --- a/Modules/_bsddb.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/_bsddb.c Fri Nov 09 01:59:49 2012 +0100 @@ -984,11 +984,9 @@ newDBObject(DBEnvObject* arg, int flags) * DBTxns and closing any open DBs first. */ if (makeDBError(err)) { if (self->myenvobj) { - Py_DECREF(self->myenvobj); - self->myenvobj = NULL; + Py_CLEAR(self->myenvobj); } - Py_DECREF(self); - self = NULL; + Py_CLEAR(self); } return self; } @@ -1017,16 +1015,13 @@ DB_dealloc(DBObject* self) PyObject_ClearWeakRefs((PyObject *) self); } if (self->myenvobj) { - Py_DECREF(self->myenvobj); - self->myenvobj = NULL; + Py_CLEAR(self->myenvobj); } if (self->associateCallback != NULL) { - Py_DECREF(self->associateCallback); - self->associateCallback = NULL; + Py_CLEAR(self->associateCallback); } if (self->btCompareCallback != NULL) { - Py_DECREF(self->btCompareCallback); - self->btCompareCallback = NULL; + Py_CLEAR(self->btCompareCallback); } Py_DECREF(self->private_obj); PyObject_Del(self); @@ -1158,8 +1153,7 @@ newDBEnvObject(int flags) err = db_env_create(&self->db_env, flags); MYDB_END_ALLOW_THREADS; if (makeDBError(err)) { - Py_DECREF(self); - self = NULL; + Py_CLEAR(self); } else { self->db_env->set_errcall(self->db_env, _db_errorCallback); @@ -1188,8 +1182,7 @@ DBEnv_dealloc(DBEnvObject* self) PyErr_Clear(); } - Py_XDECREF(self->event_notifyCallback); - self->event_notifyCallback = NULL; + Py_CLEAR(self->event_notifyCallback); if (self->in_weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject *) self); @@ -1317,8 +1310,7 @@ newDBLockObject(DBEnvObject* myenv, u_in &self->lock); MYDB_END_ALLOW_THREADS; if (makeDBError(err)) { - Py_DECREF(self); - self = NULL; + Py_CLEAR(self); } else { self->lock_initialized = 1; } @@ -1361,8 +1353,7 @@ newDBSequenceObject(DBObject* mydb, int err = db_sequence_create(&self->sequence, self->mydb->db, flags); MYDB_END_ALLOW_THREADS; if (makeDBError(err)) { - Py_DECREF(self); - self = NULL; + Py_CLEAR(self); } return self; @@ -1622,8 +1613,7 @@ DB_associate(DBObject* self, PyObject* a MYDB_END_ALLOW_THREADS; if (err) { - Py_XDECREF(secondaryDB->associateCallback); - secondaryDB->associateCallback = NULL; + Py_CLEAR(secondaryDB->associateCallback); secondaryDB->primaryDBType = 0; } @@ -3202,8 +3192,7 @@ DB_stat(DBObject* self, PyObject* args, default: PyErr_SetString(PyExc_TypeError, "Unknown DB type, unable to stat"); - Py_DECREF(d); - d = NULL; + Py_CLEAR(d); } #undef MAKE_HASH_ENTRY @@ -3691,8 +3680,7 @@ static PyObject* break; } if (item == NULL) { - Py_DECREF(list); - list = NULL; + Py_CLEAR(list); goto done; } if (PyList_Append(list, item)) { @@ -3706,8 +3694,7 @@ static PyObject* /* DB_NOTFOUND || DB_KEYEMPTY is okay, it means we got to the end */ if (err != DB_NOTFOUND && err != DB_KEYEMPTY && makeDBError(err)) { - Py_DECREF(list); - list = NULL; + Py_CLEAR(list); } done: @@ -5455,8 +5442,7 @@ DBEnv_get_data_dirs(DBEnvObject* self) for (i=0; idict, self->key)) /* XXX Error context */ PyErr_WriteUnraisable(Py_None); - Py_DECREF(self->key); - self->key = NULL; - Py_DECREF(self->dict); - self->dict = NULL; + Py_CLEAR(self->key); + Py_CLEAR(self->dict); } Py_INCREF(Py_None); return Py_None; @@ -3042,10 +3040,8 @@ static int PyCFuncPtr_set_restype(PyCFuncPtrObject *self, PyObject *ob) { if (ob == NULL) { - Py_XDECREF(self->restype); - self->restype = NULL; - Py_XDECREF(self->checker); - self->checker = NULL; + Py_CLEAR(self->restype); + Py_CLEAR(self->checker); return 0; } if (ob != Py_None && !PyType_stgdict(ob) && !PyCallable_Check(ob)) { @@ -3088,10 +3084,8 @@ PyCFuncPtr_set_argtypes(PyCFuncPtrObject PyObject *converters; if (ob == NULL || ob == Py_None) { - Py_XDECREF(self->converters); - self->converters = NULL; - Py_XDECREF(self->argtypes); - self->argtypes = NULL; + Py_CLEAR(self->converters); + Py_CLEAR(self->argtypes); } else { converters = converters_from_argtypes(ob); if (!converters) diff -r 06772ba3d001 Modules/_elementtree.c --- a/Modules/_elementtree.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/_elementtree.c Fri Nov 09 01:59:49 2012 +0100 @@ -2734,10 +2734,10 @@ xmlparser_setevents(XMLParserObject* sel target->events = events; /* clear out existing events */ - Py_XDECREF(target->start_event_obj); target->start_event_obj = NULL; - Py_XDECREF(target->end_event_obj); target->end_event_obj = NULL; - Py_XDECREF(target->start_ns_event_obj); target->start_ns_event_obj = NULL; - Py_XDECREF(target->end_ns_event_obj); target->end_ns_event_obj = NULL; + Py_CLEAR(target->start_event_obj); + Py_CLEAR(target->end_event_obj); + Py_CLEAR(target->start_ns_event_obj); + Py_CLEAR(target->end_ns_event_obj); if (event_set == Py_None) { /* default is "end" only */ diff -r 06772ba3d001 Modules/_hotshot.c --- a/Modules/_hotshot.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/_hotshot.c Fri Nov 09 01:59:49 2012 +0100 @@ -1532,8 +1532,7 @@ hotshot_profiler(PyObject *unused, PyObj } if (write_header(self)) { /* some error occurred, exception has been set */ - Py_DECREF(self); - self = NULL; + Py_CLEAR(self); } } return (PyObject *) self; diff -r 06772ba3d001 Modules/_localemodule.c --- a/Modules/_localemodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/_localemodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -75,8 +75,7 @@ copy_grouping(char* s) if (!val) break; if (PyList_SetItem(result, i, val)) { - Py_DECREF(val); - val = NULL; + Py_CLEAR(val); break; } } while (s[i] != '\0' && s[i] != CHAR_MAX); diff -r 06772ba3d001 Modules/_sqlite/connection.c --- a/Modules/_sqlite/connection.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/_sqlite/connection.c Fri Nov 09 01:59:49 2012 +0100 @@ -366,8 +366,7 @@ PyObject* pysqlite_connection_close(pysq if (self->apsw_connection) { ret = PyObject_CallMethod(self->apsw_connection, "close", ""); Py_XDECREF(ret); - Py_XDECREF(self->apsw_connection); - self->apsw_connection = NULL; + Py_CLEAR(self->apsw_connection); self->db = NULL; } else { Py_BEGIN_ALLOW_THREADS @@ -619,8 +618,7 @@ PyObject* _pysqlite_build_py_params(sqli break; } if (PyObject_AsWriteBuffer(cur_py_value, &raw_buffer, &buflen)) { - Py_DECREF(cur_py_value); - cur_py_value = NULL; + Py_CLEAR(cur_py_value); break; } memcpy(raw_buffer, sqlite3_value_blob(cur_value), buflen); diff -r 06772ba3d001 Modules/_sqlite/cursor.c --- a/Modules/_sqlite/cursor.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/_sqlite/cursor.c Fri Nov 09 01:59:49 2012 +0100 @@ -239,8 +239,7 @@ int pysqlite_build_row_cast_map(pysqlite if (converter != Py_None) { Py_DECREF(converter); } - Py_XDECREF(self->row_cast_map); - self->row_cast_map = NULL; + Py_CLEAR(self->row_cast_map); return -1; } @@ -421,8 +420,7 @@ PyObject* _pysqlite_fetch_one_row(pysqli } if (PyErr_Occurred()) { - Py_DECREF(row); - row = NULL; + Py_CLEAR(row); } return row; @@ -483,8 +481,7 @@ PyObject* _pysqlite_query_execute(pysqli allow_8bit_chars = ((self->connection->text_factory != (PyObject*)&PyUnicode_Type) && (self->connection->text_factory != pysqlite_OptimizedUnicode)); - Py_XDECREF(self->next_row); - self->next_row = NULL; + Py_CLEAR(self->next_row); if (multiple) { /* executemany() */ @@ -910,8 +907,7 @@ PyObject* pysqlite_cursor_iternext(pysql if (!self->next_row) { if (self->statement) { (void)pysqlite_statement_reset(self->statement); - Py_DECREF(self->statement); - self->statement = NULL; + Py_CLEAR(self->statement); } return NULL; } diff -r 06772ba3d001 Modules/_tkinter.c --- a/Modules/_tkinter.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/_tkinter.c Fri Nov 09 01:59:49 2012 +0100 @@ -478,8 +478,7 @@ Split(char *list) for (i = 0; i < argc; i++) { if ((w = Split(argv[i])) == NULL) { - Py_DECREF(v); - v = NULL; + Py_CLEAR(v); break; } PyTuple_SetItem(v, i, w); @@ -1977,8 +1976,7 @@ Tkapp_SplitList(PyObject *self, PyObject for (i = 0; i < argc; i++) { PyObject *s = PyString_FromString(argv[i]); if (!s || PyTuple_SetItem(v, i, s)) { - Py_DECREF(v); - v = NULL; + Py_CLEAR(v); goto finally; } } diff -r 06772ba3d001 Modules/almodule.c --- a/Modules/almodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/almodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -1654,8 +1654,7 @@ al_QueryValues(PyObject *self, PyObject item = param2python(resource, param, return_set[i], &pinfo); if (item == NULL || PyList_SetItem(res, i, item) < 0) { - Py_DECREF(res); - res = NULL; + Py_CLEAR(res); goto cleanup; } } diff -r 06772ba3d001 Modules/binascii.c --- a/Modules/binascii.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/binascii.c Fri Nov 09 01:59:49 2012 +0100 @@ -323,8 +323,7 @@ binascii_b2a_uu(PyObject *self, PyObject if (_PyString_Resize(&rv, (ascii_data - (unsigned char *)PyString_AS_STRING(rv))) < 0) { - Py_DECREF(rv); - rv = NULL; + Py_CLEAR(rv); } PyBuffer_Release(&pbin); return rv; @@ -453,8 +452,7 @@ binascii_a2b_base64(PyObject *self, PyOb */ if (bin_len > 0) { if (_PyString_Resize(&rv, bin_len) < 0) { - Py_DECREF(rv); - rv = NULL; + Py_CLEAR(rv); } } else { @@ -525,8 +523,7 @@ binascii_b2a_base64(PyObject *self, PyOb if (_PyString_Resize(&rv, (ascii_data - (unsigned char *)PyString_AS_STRING(rv))) < 0) { - Py_DECREF(rv); - rv = NULL; + Py_CLEAR(rv); } PyBuffer_Release(&pbuf); return rv; @@ -604,8 +601,7 @@ binascii_a2b_hqx(PyObject *self, PyObjec if (_PyString_Resize(&rv, (bin_data - (unsigned char *)PyString_AS_STRING(rv))) < 0) { - Py_DECREF(rv); - rv = NULL; + Py_CLEAR(rv); } if (rv) { PyObject *rrv = Py_BuildValue("Oi", rv, done); @@ -675,8 +671,7 @@ binascii_rlecode_hqx(PyObject *self, PyO if (_PyString_Resize(&rv, (out_data - (unsigned char *)PyString_AS_STRING(rv))) < 0) { - Py_DECREF(rv); - rv = NULL; + Py_CLEAR(rv); } PyBuffer_Release(&pbuf); return rv; @@ -732,8 +727,7 @@ binascii_b2a_hqx(PyObject *self, PyObjec if (_PyString_Resize(&rv, (ascii_data - (unsigned char *)PyString_AS_STRING(rv))) < 0) { - Py_DECREF(rv); - rv = NULL; + Py_CLEAR(rv); } PyBuffer_Release(&pbin); return rv; @@ -849,8 +843,7 @@ binascii_rledecode_hqx(PyObject *self, P if (_PyString_Resize(&rv, (out_data - (unsigned char *)PyString_AS_STRING(rv))) < 0) { - Py_DECREF(rv); - rv = NULL; + Py_CLEAR(rv); } PyBuffer_Release(&pin); return rv; diff -r 06772ba3d001 Modules/bz2module.c --- a/Modules/bz2module.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/bz2module.c Fri Nov 09 01:59:49 2012 +0100 @@ -566,8 +566,7 @@ BZ2File_read(BZ2FileObject *self, PyObje break; } else if (bzerror != BZ_OK) { Util_CatchBZ2Error(bzerror); - Py_DECREF(ret); - ret = NULL; + Py_CLEAR(ret); goto cleanup; } if (bytesrequested < 0) { @@ -707,8 +706,7 @@ BZ2File_readlines(BZ2FileObject *self, P } else if (bzerror != BZ_OK) { Util_CatchBZ2Error(bzerror); error: - Py_DECREF(list); - list = NULL; + Py_CLEAR(list); goto cleanup; } totalread += nread; @@ -1101,8 +1099,7 @@ BZ2File_seek(BZ2FileObject *self, PyObje ret = PyObject_CallMethod(self->file, "seek", "(i)", 0); if (!ret) goto cleanup; - Py_DECREF(ret); - ret = NULL; + Py_CLEAR(ret); self->pos = 0; self->fp = BZ2_bzReadOpen(&bzerror, PyFile_AsFile(self->file), 0, 0, NULL, 0); @@ -1215,8 +1212,7 @@ BZ2File_close(BZ2FileObject *self) ret = PyObject_CallMethod(self->file, "close", NULL); if (bzerror != BZ_OK) { Util_CatchBZ2Error(bzerror); - Py_XDECREF(ret); - ret = NULL; + Py_CLEAR(ret); } RELEASE_LOCK(self); diff -r 06772ba3d001 Modules/cPickle.c --- a/Modules/cPickle.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/cPickle.c Fri Nov 09 01:59:49 2012 +0100 @@ -325,8 +325,7 @@ Pdata_popList(Pdata *self, int start) #define FREE_ARG_TUP(self) { \ if (Py_REFCNT(self->arg) > 1) { \ - Py_DECREF(self->arg); \ - self->arg=NULL; \ + Py_CLEAR(self->arg); \ } \ } diff -r 06772ba3d001 Modules/cdmodule.c --- a/Modules/cdmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/cdmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -535,10 +535,8 @@ CD_deleteparser(cdparserobject *self, Py /* no sense in keeping the callbacks, so remove them */ for (i = 0; i < NCALLBACKS; i++) { - Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallback); - self->ob_cdcallbacks[i].ob_cdcallback = NULL; - Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallbackarg); - self->ob_cdcallbacks[i].ob_cdcallbackarg = NULL; + Py_CLEAR(self->ob_cdcallbacks[i].ob_cdcallback); + Py_CLEAR(self->ob_cdcallbacks[i].ob_cdcallbackarg); } Py_INCREF(Py_None); @@ -588,11 +586,9 @@ CD_removecallback(cdparserobject *self, CDremovecallback(self->ob_cdparser, (CDDATATYPES) type); - Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallback); - self->ob_cdcallbacks[type].ob_cdcallback = NULL; + Py_CLEAR(self->ob_cdcallbacks[type].ob_cdcallback); - Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallbackarg); - self->ob_cdcallbacks[type].ob_cdcallbackarg = NULL; + Py_CLEAR(self->ob_cdcallbacks[type].ob_cdcallbackarg); Py_INCREF(Py_None); return Py_None; @@ -668,10 +664,8 @@ cdparser_dealloc(cdparserobject *self) int i; for (i = 0; i < NCALLBACKS; i++) { - Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallback); - self->ob_cdcallbacks[i].ob_cdcallback = NULL; - Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallbackarg); - self->ob_cdcallbacks[i].ob_cdcallbackarg = NULL; + Py_CLEAR(self->ob_cdcallbacks[i].ob_cdcallback); + Py_CLEAR(self->ob_cdcallbacks[i].ob_cdcallbackarg); } CDdeleteparser(self->ob_cdparser); PyObject_Del(self); diff -r 06772ba3d001 Modules/cjkcodecs/multibytecodec.c --- a/Modules/cjkcodecs/multibytecodec.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/cjkcodecs/multibytecodec.c Fri Nov 09 01:59:49 2012 +0100 @@ -1310,8 +1310,7 @@ mbstreamreader_iread(MultibyteStreamRead finalsize = (Py_ssize_t)(buf.outbuf - PyUnicode_AS_UNICODE(buf.outobj)); - Py_DECREF(cres); - cres = NULL; + Py_CLEAR(cres); if (sizehint < 0 || finalsize != 0 || rsize == 0) break; diff -r 06772ba3d001 Modules/datetimemodule.c --- a/Modules/datetimemodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/datetimemodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -954,8 +954,7 @@ call_tzname(PyObject *tzinfo, PyObject * PyErr_Format(PyExc_TypeError, "tzinfo.tzname() must " "return None or a string, not '%s'", Py_TYPE(result)->tp_name); - Py_DECREF(result); - result = NULL; + Py_CLEAR(result); } return result; } @@ -1511,8 +1510,7 @@ delta_to_microseconds(PyDateTime_Delta * x2 = PyNumber_Multiply(x1, seconds_per_day); /* days in seconds */ if (x2 == NULL) goto Done; - Py_DECREF(x1); - x1 = NULL; + Py_CLEAR(x1); /* x2 has days in seconds */ x1 = PyInt_FromLong(GET_TD_SECONDS(self)); /* seconds */ @@ -1522,15 +1520,13 @@ delta_to_microseconds(PyDateTime_Delta * if (x3 == NULL) goto Done; Py_DECREF(x1); - Py_DECREF(x2); - x2 = NULL; + Py_CLEAR(x2); /* x3 has days+seconds in seconds */ x1 = PyNumber_Multiply(x3, us_per_second); /* us */ if (x1 == NULL) goto Done; - Py_DECREF(x3); - x3 = NULL; + Py_CLEAR(x3); /* x1 has days+seconds in us */ x2 = PyInt_FromLong(GET_TD_MICROSECONDS(self)); diff -r 06772ba3d001 Modules/flmodule.c --- a/Modules/flmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/flmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -97,10 +97,8 @@ forgetgeneric(genericobject *g) { int i, n; - Py_XDECREF(g->ob_callback); - g->ob_callback = NULL; - Py_XDECREF(g->ob_callback_arg); - g->ob_callback_arg = NULL; + Py_CLEAR(g->ob_callback); + Py_CLEAR(g->ob_callback_arg); if (allgenerics == NULL) return; /* No objects known yet */ n = PyList_Size(allgenerics); @@ -132,10 +130,8 @@ releaseobjects(FL_FORM *form) /* The object is now unreachable for do_forms and check_forms, so delete it from the list of known objects */ - Py_XDECREF(g->ob_callback); - g->ob_callback = NULL; - Py_XDECREF(g->ob_callback_arg); - g->ob_callback_arg = NULL; + Py_CLEAR(g->ob_callback); + Py_CLEAR(g->ob_callback_arg); PyList_SetItem(allgenerics, i, (PyObject *)NULL); nfreeslots++; } diff -r 06772ba3d001 Modules/fmmodule.c --- a/Modules/fmmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/fmmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -208,8 +208,7 @@ clientproc(char *fontname) Py_DECREF(v); } if (err != 0) { - Py_DECREF(fontlist); - fontlist = NULL; + Py_CLEAR(fontlist); } } diff -r 06772ba3d001 Modules/nismodule.c --- a/Modules/nismodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/nismodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -405,8 +405,7 @@ nis_maps (PyObject *self, PyObject *args PyObject *str = PyString_FromString(maps->map); if (!str || PyList_Append(list, str) < 0) { - Py_DECREF(list); - list = NULL; + Py_CLEAR(list); break; } Py_DECREF(str); diff -r 06772ba3d001 Modules/posixmodule.c --- a/Modules/posixmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/posixmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -2148,14 +2148,12 @@ posix_listdir(PyObject *self, PyObject * wcscmp(wFileData.cFileName, L"..") != 0) { v = PyUnicode_FromUnicode(wFileData.cFileName, wcslen(wFileData.cFileName)); if (v == NULL) { - Py_DECREF(d); - d = NULL; + Py_CLEAR(d); break; } if (PyList_Append(d, v) != 0) { Py_DECREF(v); - Py_DECREF(d); - d = NULL; + Py_CLEAR(d); break; } Py_DECREF(v); @@ -2216,14 +2214,12 @@ posix_listdir(PyObject *self, PyObject * strcmp(FileData.cFileName, "..") != 0) { v = PyString_FromString(FileData.cFileName); if (v == NULL) { - Py_DECREF(d); - d = NULL; + Py_CLEAR(d); break; } if (PyList_Append(d, v) != 0) { Py_DECREF(v); - Py_DECREF(d); - d = NULL; + Py_CLEAR(d); break; } Py_DECREF(v); @@ -2304,14 +2300,12 @@ posix_listdir(PyObject *self, PyObject * v = PyString_FromString(namebuf); if (v == NULL) { - Py_DECREF(d); - d = NULL; + Py_CLEAR(d); break; } if (PyList_Append(d, v) != 0) { Py_DECREF(v); - Py_DECREF(d); - d = NULL; + Py_CLEAR(d); break; } Py_DECREF(v); @@ -2369,8 +2363,7 @@ posix_listdir(PyObject *self, PyObject * continue; v = PyString_FromStringAndSize(ep->d_name, NAMLEN(ep)); if (v == NULL) { - Py_DECREF(d); - d = NULL; + Py_CLEAR(d); break; } #ifdef Py_USING_UNICODE @@ -2393,8 +2386,7 @@ posix_listdir(PyObject *self, PyObject * #endif if (PyList_Append(d, v) != 0) { Py_DECREF(v); - Py_DECREF(d); - d = NULL; + Py_CLEAR(d); break; } Py_DECREF(v); @@ -3946,8 +3938,7 @@ posix_getgroups(PyObject *self, PyObject for (i = 0; i < n; ++i) { PyObject *o = PyInt_FromLong((long)alt_grouplist[i]); if (o == NULL) { - Py_DECREF(result); - result = NULL; + Py_CLEAR(result); break; } PyList_SET_ITEM(result, i, o); @@ -4936,8 +4927,7 @@ static int _PyPclose(FILE *file) if (PyDict_Size(_PyPopenProcs) == 0) { - Py_DECREF(_PyPopenProcs); - _PyPopenProcs = NULL; + Py_CLEAR(_PyPopenProcs); } } /* if object retrieval ok */ @@ -5684,8 +5674,7 @@ static int _PyPclose(FILE *file) PyDict_DelItem(_PyPopenProcs, fileObj); if (PyDict_Size(_PyPopenProcs) == 0) { - Py_DECREF(_PyPopenProcs); - _PyPopenProcs = NULL; + Py_CLEAR(_PyPopenProcs); } } /* if object retrieval ok */ diff -r 06772ba3d001 Modules/pyexpat.c --- a/Modules/pyexpat.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/pyexpat.c Fri Nov 09 01:59:49 2012 +0100 @@ -364,8 +364,7 @@ call_with_frame(PyCodeObject *c, PyObjec } else { if (trace_frame(tstate, f, PyTrace_RETURN, res) < 0) { - Py_XDECREF(res); - res = NULL; + Py_CLEAR(res); } } #else @@ -1927,8 +1926,7 @@ MODULE_INITFUNC(void) PyObject *item = Py_BuildValue("si", features[i].name, features[i].value); if (item == NULL) { - Py_DECREF(list); - list = NULL; + Py_CLEAR(list); break; } ok = PyList_Append(list, item); diff -r 06772ba3d001 Modules/readline.c --- a/Modules/readline.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/readline.c Fri Nov 09 01:59:49 2012 +0100 @@ -200,8 +200,7 @@ set_hook(const char *funcname, PyObject if (!PyArg_ParseTuple(args, buf, &function)) return NULL; if (function == Py_None) { - Py_XDECREF(*hook_var); - *hook_var = NULL; + Py_CLEAR(*hook_var); } else if (PyCallable_Check(function)) { PyObject *tmp = *hook_var; @@ -775,13 +774,13 @@ on_completion_display_matches_hook(char r = PyObject_CallFunction(completion_display_matches_hook, "sOi", matches[0], m, max_length); - Py_DECREF(m); m=NULL; + Py_CLEAR(m); if (r == NULL || (r != Py_None && PyInt_AsLong(r) == -1 && PyErr_Occurred())) { goto error; } - Py_XDECREF(r); r=NULL; + Py_CLEAR(r); if (0) { error: diff -r 06772ba3d001 Modules/selectmodule.c --- a/Modules/selectmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/selectmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -71,8 +71,7 @@ reap_obj(pylist fd2obj[FD_SETSIZE + 1]) { int i; for (i = 0; i < FD_SETSIZE + 1 && fd2obj[i].sentinel >= 0; i++) { - Py_XDECREF(fd2obj[i].obj); - fd2obj[i].obj = NULL; + Py_CLEAR(fd2obj[i].obj); } fd2obj[0].sentinel = -1; } diff -r 06772ba3d001 Modules/signalmodule.c --- a/Modules/signalmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/signalmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -871,12 +871,9 @@ finisignal(void) Py_XDECREF(func); } - Py_XDECREF(IntHandler); - IntHandler = NULL; - Py_XDECREF(DefaultHandler); - DefaultHandler = NULL; - Py_XDECREF(IgnoreHandler); - IgnoreHandler = NULL; + Py_CLEAR(IntHandler); + Py_CLEAR(DefaultHandler); + Py_CLEAR(IgnoreHandler); } diff -r 06772ba3d001 Modules/svmodule.c --- a/Modules/svmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/svmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -279,8 +279,7 @@ capture_dealloc(captureobject *self) (void)svUnlockCaptureData(self->ob_svideo->ob_svideo, self->ob_capture); self->ob_capture = NULL; - Py_DECREF(self->ob_svideo); - self->ob_svideo = NULL; + Py_CLEAR(self->ob_svideo); } PyObject_Del(self); } diff -r 06772ba3d001 Modules/syslogmodule.c --- a/Modules/syslogmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/syslogmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -182,8 +182,7 @@ syslog_closelog(PyObject *self, PyObject { if (S_log_open) { closelog(); - Py_XDECREF(S_ident_o); - S_ident_o = NULL; + Py_CLEAR(S_ident_o); S_log_open = 0; } Py_INCREF(Py_None); diff -r 06772ba3d001 Modules/zlibmodule.c --- a/Modules/zlibmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Modules/zlibmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -456,8 +456,7 @@ PyZlib_objcompress(compobject *self, PyO if (err != Z_OK && err != Z_BUF_ERROR) { zlib_error(self->zst, err, "while compressing"); - Py_DECREF(RetVal); - RetVal = NULL; + Py_CLEAR(RetVal); goto error; } _PyString_Resize(&RetVal, self->zst.total_out - start_total_out); @@ -554,8 +553,7 @@ PyZlib_objdecompress(compobject *self, P self->unconsumed_tail = PyString_FromStringAndSize("", 0); } if(!self->unconsumed_tail) { - Py_DECREF(RetVal); - RetVal = NULL; + Py_CLEAR(RetVal); goto error; } @@ -579,8 +577,7 @@ PyZlib_objdecompress(compobject *self, P */ } else if (err != Z_OK && err != Z_BUF_ERROR) { zlib_error(self->zst, err, "while decompressing"); - Py_DECREF(RetVal); - RetVal = NULL; + Py_CLEAR(RetVal); goto error; } @@ -653,8 +650,7 @@ PyZlib_flush(compobject *self, PyObject err = deflateEnd(&(self->zst)); if (err != Z_OK) { zlib_error(self->zst, err, "from deflateEnd()"); - Py_DECREF(RetVal); - RetVal = NULL; + Py_CLEAR(RetVal); goto error; } else @@ -666,8 +662,7 @@ PyZlib_flush(compobject *self, PyObject */ } else if (err!=Z_OK && err!=Z_BUF_ERROR) { zlib_error(self->zst, err, "while flushing"); - Py_DECREF(RetVal); - RetVal = NULL; + Py_CLEAR(RetVal); goto error; } @@ -839,8 +834,7 @@ PyZlib_unflush(compobject *self, PyObjec self->is_initialised = 0; if (err != Z_OK) { zlib_error(self->zst, err, "from inflateEnd()"); - Py_DECREF(retval); - retval = NULL; + Py_CLEAR(retval); goto error; } } diff -r 06772ba3d001 Objects/abstract.c --- a/Objects/abstract.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/abstract.c Fri Nov 09 01:59:49 2012 +0100 @@ -856,8 +856,7 @@ done1: "%.100s.__format__ must return string or " "unicode, not %.100s", Py_TYPE(obj)->tp_name, Py_TYPE(result)->tp_name); - Py_DECREF(result); - result = NULL; + Py_CLEAR(result); goto done; } @@ -3086,8 +3085,7 @@ PyObject_GetIter(PyObject *o) "iter() returned non-iterator " "of type '%.100s'", res->ob_type->tp_name); - Py_DECREF(res); - res = NULL; + Py_CLEAR(res); } return res; } diff -r 06772ba3d001 Objects/classobject.c --- a/Objects/classobject.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/classobject.c Fri Nov 09 01:59:49 2012 +0100 @@ -573,23 +573,20 @@ PyInstance_New(PyObject *klass, PyObject PyDict_Size(kw) != 0))) { PyErr_SetString(PyExc_TypeError, "this constructor takes no arguments"); - Py_DECREF(inst); - inst = NULL; + Py_CLEAR(inst); } } else { PyObject *res = PyEval_CallObjectWithKeywords(init, arg, kw); Py_DECREF(init); if (res == NULL) { - Py_DECREF(inst); - inst = NULL; + Py_CLEAR(inst); } else { if (res != Py_None) { PyErr_SetString(PyExc_TypeError, "__init__() should return None"); - Py_DECREF(inst); - inst = NULL; + Py_CLEAR(inst); } Py_DECREF(res); } @@ -2078,8 +2075,7 @@ instance_getiter(PyInstanceObject *self) "__iter__ returned non-iterator " "of type '%.100s'", res->ob_type->tp_name); - Py_DECREF(res); - res = NULL; + Py_CLEAR(res); } return res; } @@ -2429,8 +2425,7 @@ instancemethod_repr(PyMethodObject *a) PyErr_Clear(); } else if (!PyString_Check(funcname)) { - Py_DECREF(funcname); - funcname = NULL; + Py_CLEAR(funcname); } else sfuncname = PyString_AS_STRING(funcname); @@ -2444,8 +2439,7 @@ instancemethod_repr(PyMethodObject *a) PyErr_Clear(); } else if (!PyString_Check(klassname)) { - Py_DECREF(klassname); - klassname = NULL; + Py_CLEAR(klassname); } else sklassname = PyString_AS_STRING(klassname); diff -r 06772ba3d001 Objects/descrobject.c --- a/Objects/descrobject.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/descrobject.c Fri Nov 09 01:59:49 2012 +0100 @@ -617,8 +617,7 @@ descr_new(PyTypeObject *descrtype, PyTyp descr->d_type = type; descr->d_name = PyString_InternFromString(name); if (descr->d_name == NULL) { - Py_DECREF(descr); - descr = NULL; + Py_CLEAR(descr); } } return descr; diff -r 06772ba3d001 Objects/exceptions.c --- a/Objects/exceptions.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/exceptions.c Fri Nov 09 01:59:49 2012 +0100 @@ -349,8 +349,7 @@ BaseException_set_message(PyBaseExceptio if (PyDict_DelItemString(self->dict, "message") < 0) return -1; } - Py_XDECREF(self->message); - self->message = NULL; + Py_CLEAR(self->message); return 0; } diff -r 06772ba3d001 Objects/fileobject.c --- a/Objects/fileobject.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/fileobject.c Fri Nov 09 01:59:49 2012 +0100 @@ -499,8 +499,7 @@ PyFile_FromString(char *name, char *mode f = (PyFileObject *)PyFile_FromFile((FILE *)NULL, name, mode, fclose); if (f != NULL) { if (open_the_file(f, name, mode) == NULL) { - Py_DECREF(f); - f = NULL; + Py_CLEAR(f); } } return (PyObject *)f; @@ -1579,8 +1578,7 @@ PyFile_GetLine(PyObject *f, int n) Py_DECREF(args); if (result != NULL && !PyString_Check(result) && !PyUnicode_Check(result)) { - Py_DECREF(result); - result = NULL; + Py_CLEAR(result); PyErr_SetString(PyExc_TypeError, "object.readline() returned non-string"); } @@ -1590,8 +1588,7 @@ PyFile_GetLine(PyObject *f, int n) char *s = PyString_AS_STRING(result); Py_ssize_t len = PyString_GET_SIZE(result); if (len == 0) { - Py_DECREF(result); - result = NULL; + Py_CLEAR(result); PyErr_SetString(PyExc_EOFError, "EOF when reading a line"); } @@ -1613,8 +1610,7 @@ PyFile_GetLine(PyObject *f, int n) Py_UNICODE *s = PyUnicode_AS_UNICODE(result); Py_ssize_t len = PyUnicode_GET_SIZE(result); if (len == 0) { - Py_DECREF(result); - result = NULL; + Py_CLEAR(result); PyErr_SetString(PyExc_EOFError, "EOF when reading a line"); } diff -r 06772ba3d001 Objects/frameobject.c --- a/Objects/frameobject.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/frameobject.c Fri Nov 09 01:59:49 2012 +0100 @@ -979,6 +979,5 @@ void PyFrame_Fini(void) { (void)PyFrame_ClearFreeList(); - Py_XDECREF(builtin_object); - builtin_object = NULL; + Py_CLEAR(builtin_object); } diff -r 06772ba3d001 Objects/genobject.c --- a/Objects/genobject.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/genobject.c Fri Nov 09 01:59:49 2012 +0100 @@ -93,8 +93,7 @@ gen_send_ex(PyGenObject *gen, PyObject * /* If the generator just returned (as opposed to yielding), signal * that the generator is exhausted. */ if (result == Py_None && f->f_stacktop == NULL) { - Py_DECREF(result); - result = NULL; + Py_CLEAR(result); /* Set exception if not called by gen_iternext() */ if (arg) PyErr_SetNone(PyExc_StopIteration); diff -r 06772ba3d001 Objects/longobject.c --- a/Objects/longobject.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/longobject.c Fri Nov 09 01:59:49 2012 +0100 @@ -3547,8 +3547,7 @@ long_pow(PyObject *v, PyObject *w, PyObj Error: if (z != NULL) { - Py_DECREF(z); - z = NULL; + Py_CLEAR(z); } /* fall through */ Done: diff -r 06772ba3d001 Objects/object.c --- a/Objects/object.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/object.c Fri Nov 09 01:59:49 2012 +0100 @@ -1947,8 +1947,7 @@ static PyObject * PyErr_Format(PyExc_TypeError, "__dir__() must return a list, not %.200s", Py_TYPE(result)->tp_name); - Py_DECREF(result); - result = NULL; + Py_CLEAR(result); } } @@ -1975,8 +1974,7 @@ PyObject_Dir(PyObject *obj) if (result != NULL && PyList_Sort(result) != 0) { /* sorting the list failed */ - Py_DECREF(result); - result = NULL; + Py_CLEAR(result); } return result; diff -r 06772ba3d001 Objects/stringobject.c --- a/Objects/stringobject.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/stringobject.c Fri Nov 09 01:59:49 2012 +0100 @@ -3855,8 +3855,7 @@ PyString_Concat(register PyObject **pv, if (*pv == NULL) return; if (w == NULL || !PyString_Check(*pv)) { - Py_DECREF(*pv); - *pv = NULL; + Py_CLEAR(*pv); return; } v = string_concat((PyStringObject *) *pv, w); @@ -4780,11 +4779,9 @@ PyString_Fini(void) { int i; for (i = 0; i < UCHAR_MAX + 1; i++) { - Py_XDECREF(characters[i]); - characters[i] = NULL; + Py_CLEAR(characters[i]); } - Py_XDECREF(nullstring); - nullstring = NULL; + Py_CLEAR(nullstring); } void _Py_ReleaseInternedStrings(void) @@ -4834,6 +4831,5 @@ void _Py_ReleaseInternedStrings(void) "mortal/immortal\n", mortal_size, immortal_size); Py_DECREF(keys); PyDict_Clear(interned); - Py_DECREF(interned); - interned = NULL; + Py_CLEAR(interned); } diff -r 06772ba3d001 Objects/tupleobject.c --- a/Objects/tupleobject.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/tupleobject.c Fri Nov 09 01:59:49 2012 +0100 @@ -881,8 +881,7 @@ int _Py_ForgetReference((PyObject *) v); /* DECREF items deleted by shrinkage */ for (i = newsize; i < oldsize; i++) { - Py_XDECREF(v->ob_item[i]); - v->ob_item[i] = NULL; + Py_CLEAR(v->ob_item[i]); } sv = PyObject_GC_Resize(PyTupleObject, v, newsize); if (sv == NULL) { @@ -928,8 +927,7 @@ PyTuple_Fini(void) #if PyTuple_MAXSAVESIZE > 0 /* empty tuples are used all over the place and applications may * rely on the fact that an empty tuple is a singleton. */ - Py_XDECREF(free_list[0]); - free_list[0] = NULL; + Py_CLEAR(free_list[0]); (void)PyTuple_ClearFreeList(); #endif diff -r 06772ba3d001 Objects/typeobject.c --- a/Objects/typeobject.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/typeobject.c Fri Nov 09 01:59:49 2012 +0100 @@ -682,8 +682,7 @@ type_repr(PyTypeObject *type) if (mod == NULL) PyErr_Clear(); else if (!PyString_Check(mod)) { - Py_DECREF(mod); - mod = NULL; + Py_CLEAR(mod); } name = type_name(type, NULL); if (name == NULL) { @@ -739,8 +738,7 @@ type_call(PyTypeObject *type, PyObject * if (PyType_HasFeature(type, Py_TPFLAGS_HAVE_CLASS) && type->tp_init != NULL && type->tp_init(obj, args, kwds) < 0) { - Py_DECREF(obj); - obj = NULL; + Py_CLEAR(obj); } } return obj; @@ -2980,8 +2978,7 @@ object_repr(PyObject *self) if (mod == NULL) PyErr_Clear(); else if (!PyString_Check(mod)) { - Py_DECREF(mod); - mod = NULL; + Py_CLEAR(mod); } name = type_name(type, NULL); if (name == NULL) { @@ -3190,8 +3187,7 @@ slotnames(PyObject *cls) { PyErr_SetString(PyExc_TypeError, "copy_reg._slotnames didn't return a list or None"); - Py_DECREF(slotnames); - slotnames = NULL; + Py_CLEAR(slotnames); } return slotnames; diff -r 06772ba3d001 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Objects/unicodeobject.c Fri Nov 09 01:59:49 2012 +0100 @@ -3486,8 +3486,7 @@ static void make_encode_exception(PyObje goto onError; return; onError: - Py_DECREF(*exceptionObject); - *exceptionObject = NULL; + Py_CLEAR(*exceptionObject); } } @@ -4758,8 +4757,7 @@ static void make_translate_exception(PyO goto onError; return; onError: - Py_DECREF(*exceptionObject); - *exceptionObject = NULL; + Py_CLEAR(*exceptionObject); } } @@ -8875,13 +8873,11 @@ void { int i; - Py_XDECREF(unicode_empty); - unicode_empty = NULL; + Py_CLEAR(unicode_empty); for (i = 0; i < 256; i++) { if (unicode_latin1[i]) { - Py_DECREF(unicode_latin1[i]); - unicode_latin1[i] = NULL; + Py_CLEAR(unicode_latin1[i]); } } (void)PyUnicode_ClearFreeList(); diff -r 06772ba3d001 Python/Python-ast.c --- a/Python/Python-ast.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Python/Python-ast.c Fri Nov 09 01:59:49 2012 +0100 @@ -3353,8 +3353,7 @@ obj2ast_mod(PyObject* obj, mod_ty* out, if (res != 0) goto failed; asdl_seq_SET(body, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module"); return 1; @@ -3389,8 +3388,7 @@ obj2ast_mod(PyObject* obj, mod_ty* out, if (res != 0) goto failed; asdl_seq_SET(body, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive"); return 1; @@ -3412,8 +3410,7 @@ obj2ast_mod(PyObject* obj, mod_ty* out, if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &body, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression"); return 1; @@ -3448,8 +3445,7 @@ obj2ast_mod(PyObject* obj, mod_ty* out, if (res != 0) goto failed; asdl_seq_SET(body, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite"); return 1; @@ -3486,8 +3482,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_int(tmp, &lineno, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt"); return 1; @@ -3498,8 +3493,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_int(tmp, &col_offset, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); return 1; @@ -3520,8 +3514,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_identifier(tmp, &name, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef"); return 1; @@ -3532,8 +3525,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_arguments(tmp, &args, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef"); return 1; @@ -3557,8 +3549,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(body, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef"); return 1; @@ -3582,8 +3573,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(decorator_list, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef"); return 1; @@ -3609,8 +3599,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_identifier(tmp, &name, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef"); return 1; @@ -3634,8 +3623,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(bases, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef"); return 1; @@ -3659,8 +3647,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(body, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef"); return 1; @@ -3684,8 +3671,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(decorator_list, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef"); return 1; @@ -3708,8 +3694,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &value, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { value = NULL; } @@ -3743,8 +3728,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(targets, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete"); return 1; @@ -3780,8 +3764,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(targets, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign"); return 1; @@ -3792,8 +3775,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &value, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign"); return 1; @@ -3817,8 +3799,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &target, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign"); return 1; @@ -3829,8 +3810,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_operator(tmp, &op, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign"); return 1; @@ -3841,8 +3821,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &value, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign"); return 1; @@ -3866,8 +3845,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &dest, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { dest = NULL; } @@ -3890,8 +3868,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(values, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Print"); return 1; @@ -3902,8 +3879,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_bool(tmp, &nl, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"nl\" missing from Print"); return 1; @@ -3928,8 +3904,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &target, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For"); return 1; @@ -3940,8 +3915,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &iter, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For"); return 1; @@ -3965,8 +3939,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(body, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For"); return 1; @@ -3990,8 +3963,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(orelse, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For"); return 1; @@ -4016,8 +3988,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &test, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While"); return 1; @@ -4041,8 +4012,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(body, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While"); return 1; @@ -4066,8 +4036,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(orelse, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While"); return 1; @@ -4091,8 +4060,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &test, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If"); return 1; @@ -4116,8 +4084,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(body, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If"); return 1; @@ -4141,8 +4108,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(orelse, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If"); return 1; @@ -4166,8 +4132,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &context_expr, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from With"); return 1; @@ -4178,8 +4143,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &optional_vars, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { optional_vars = NULL; } @@ -4202,8 +4166,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(body, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With"); return 1; @@ -4228,8 +4191,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &type, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { type = NULL; } @@ -4239,8 +4201,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &inst, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { inst = NULL; } @@ -4250,8 +4211,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &tback, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { tback = NULL; } @@ -4287,8 +4247,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(body, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from TryExcept"); return 1; @@ -4312,8 +4271,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(handlers, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from TryExcept"); return 1; @@ -4337,8 +4295,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(orelse, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from TryExcept"); return 1; @@ -4375,8 +4332,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(body, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from TryFinally"); return 1; @@ -4400,8 +4356,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(finalbody, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from TryFinally"); return 1; @@ -4424,8 +4379,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &test, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert"); return 1; @@ -4436,8 +4390,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &msg, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { msg = NULL; } @@ -4471,8 +4424,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(names, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import"); return 1; @@ -4496,8 +4448,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_identifier(tmp, &module, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { module = NULL; } @@ -4520,8 +4471,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(names, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom"); return 1; @@ -4532,8 +4482,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_int(tmp, &level, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { level = 0; } @@ -4557,8 +4506,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &body, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Exec"); return 1; @@ -4569,8 +4517,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &globals, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { globals = NULL; } @@ -4580,8 +4527,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &locals, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { locals = NULL; } @@ -4615,8 +4561,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (res != 0) goto failed; asdl_seq_SET(names, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global"); return 1; @@ -4638,8 +4583,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &value, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr"); return 1; @@ -4706,8 +4650,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_int(tmp, &lineno, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr"); return 1; @@ -4718,8 +4661,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_int(tmp, &col_offset, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); return 1; @@ -4738,8 +4680,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_boolop(tmp, &op, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp"); return 1; @@ -4763,8 +4704,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(values, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp"); return 1; @@ -4788,8 +4728,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &left, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp"); return 1; @@ -4800,8 +4739,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_operator(tmp, &op, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp"); return 1; @@ -4812,8 +4750,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &right, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp"); return 1; @@ -4836,8 +4773,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_unaryop(tmp, &op, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp"); return 1; @@ -4848,8 +4784,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &operand, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp"); return 1; @@ -4872,8 +4807,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_arguments(tmp, &args, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda"); return 1; @@ -4884,8 +4818,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &body, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda"); return 1; @@ -4909,8 +4842,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &test, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp"); return 1; @@ -4921,8 +4853,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &body, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp"); return 1; @@ -4933,8 +4864,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &orelse, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp"); return 1; @@ -4970,8 +4900,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(keys, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict"); return 1; @@ -4995,8 +4924,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(values, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict"); return 1; @@ -5031,8 +4959,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(elts, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set"); return 1; @@ -5055,8 +4982,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &elt, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp"); return 1; @@ -5080,8 +5006,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(generators, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp"); return 1; @@ -5104,8 +5029,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &elt, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp"); return 1; @@ -5129,8 +5053,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(generators, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp"); return 1; @@ -5154,8 +5077,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &key, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp"); return 1; @@ -5166,8 +5088,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &value, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp"); return 1; @@ -5191,8 +5112,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(generators, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp"); return 1; @@ -5216,8 +5136,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &elt, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp"); return 1; @@ -5241,8 +5160,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(generators, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp"); return 1; @@ -5264,8 +5182,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &value, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { value = NULL; } @@ -5288,8 +5205,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &left, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare"); return 1; @@ -5313,8 +5229,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(ops, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare"); return 1; @@ -5338,8 +5253,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(comparators, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare"); return 1; @@ -5366,8 +5280,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &func, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call"); return 1; @@ -5391,8 +5304,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(args, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call"); return 1; @@ -5416,8 +5328,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(keywords, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call"); return 1; @@ -5428,8 +5339,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &starargs, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { starargs = NULL; } @@ -5439,8 +5349,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &kwargs, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { kwargs = NULL; } @@ -5462,8 +5371,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &value, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Repr"); return 1; @@ -5485,8 +5393,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_object(tmp, &n, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num"); return 1; @@ -5508,8 +5415,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_string(tmp, &s, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Str"); return 1; @@ -5533,8 +5439,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &value, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute"); return 1; @@ -5545,8 +5450,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_identifier(tmp, &attr, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute"); return 1; @@ -5557,8 +5461,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr_context(tmp, &ctx, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute"); return 1; @@ -5582,8 +5485,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &value, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript"); return 1; @@ -5594,8 +5496,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_slice(tmp, &slice, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript"); return 1; @@ -5606,8 +5507,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr_context(tmp, &ctx, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript"); return 1; @@ -5630,8 +5530,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_identifier(tmp, &id, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name"); return 1; @@ -5642,8 +5541,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr_context(tmp, &ctx, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name"); return 1; @@ -5679,8 +5577,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(elts, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List"); return 1; @@ -5691,8 +5588,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr_context(tmp, &ctx, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List"); return 1; @@ -5728,8 +5624,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (res != 0) goto failed; asdl_seq_SET(elts, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple"); return 1; @@ -5740,8 +5635,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out if (tmp == NULL) goto failed; res = obj2ast_expr_context(tmp, &ctx, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple"); return 1; @@ -5858,8 +5752,7 @@ obj2ast_slice(PyObject* obj, slice_ty* o if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &lower, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { lower = NULL; } @@ -5869,8 +5762,7 @@ obj2ast_slice(PyObject* obj, slice_ty* o if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &upper, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { upper = NULL; } @@ -5880,8 +5772,7 @@ obj2ast_slice(PyObject* obj, slice_ty* o if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &step, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { step = NULL; } @@ -5915,8 +5806,7 @@ obj2ast_slice(PyObject* obj, slice_ty* o if (res != 0) goto failed; asdl_seq_SET(dims, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"dims\" missing from ExtSlice"); return 1; @@ -5938,8 +5828,7 @@ obj2ast_slice(PyObject* obj, slice_ty* o if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &value, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Index"); return 1; @@ -6255,8 +6144,7 @@ obj2ast_comprehension(PyObject* obj, com if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &target, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension"); return 1; @@ -6267,8 +6155,7 @@ obj2ast_comprehension(PyObject* obj, com if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &iter, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension"); return 1; @@ -6292,8 +6179,7 @@ obj2ast_comprehension(PyObject* obj, com if (res != 0) goto failed; asdl_seq_SET(ifs, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension"); return 1; @@ -6324,8 +6210,7 @@ obj2ast_excepthandler(PyObject* obj, exc if (tmp == NULL) goto failed; res = obj2ast_int(tmp, &lineno, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler"); return 1; @@ -6336,8 +6221,7 @@ obj2ast_excepthandler(PyObject* obj, exc if (tmp == NULL) goto failed; res = obj2ast_int(tmp, &col_offset, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler"); return 1; @@ -6357,8 +6241,7 @@ obj2ast_excepthandler(PyObject* obj, exc if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &type, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { type = NULL; } @@ -6368,8 +6251,7 @@ obj2ast_excepthandler(PyObject* obj, exc if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &name, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { name = NULL; } @@ -6392,8 +6274,7 @@ obj2ast_excepthandler(PyObject* obj, exc if (res != 0) goto failed; asdl_seq_SET(body, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler"); return 1; @@ -6440,8 +6321,7 @@ obj2ast_arguments(PyObject* obj, argumen if (res != 0) goto failed; asdl_seq_SET(args, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments"); return 1; @@ -6452,8 +6332,7 @@ obj2ast_arguments(PyObject* obj, argumen if (tmp == NULL) goto failed; res = obj2ast_identifier(tmp, &vararg, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { vararg = NULL; } @@ -6463,8 +6342,7 @@ obj2ast_arguments(PyObject* obj, argumen if (tmp == NULL) goto failed; res = obj2ast_identifier(tmp, &kwarg, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { kwarg = NULL; } @@ -6487,8 +6365,7 @@ obj2ast_arguments(PyObject* obj, argumen if (res != 0) goto failed; asdl_seq_SET(defaults, i, value); } - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments"); return 1; @@ -6513,8 +6390,7 @@ obj2ast_keyword(PyObject* obj, keyword_t if (tmp == NULL) goto failed; res = obj2ast_identifier(tmp, &arg, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from keyword"); return 1; @@ -6525,8 +6401,7 @@ obj2ast_keyword(PyObject* obj, keyword_t if (tmp == NULL) goto failed; res = obj2ast_expr(tmp, &value, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword"); return 1; @@ -6551,8 +6426,7 @@ obj2ast_alias(PyObject* obj, alias_ty* o if (tmp == NULL) goto failed; res = obj2ast_identifier(tmp, &name, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias"); return 1; @@ -6563,8 +6437,7 @@ obj2ast_alias(PyObject* obj, alias_ty* o if (tmp == NULL) goto failed; res = obj2ast_identifier(tmp, &asname, arena); if (res != 0) goto failed; - Py_XDECREF(tmp); - tmp = NULL; + Py_CLEAR(tmp); } else { asname = NULL; } diff -r 06772ba3d001 Python/bltinmodule.c --- a/Python/bltinmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Python/bltinmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -2327,8 +2327,7 @@ builtin_sum(PyObject *self, PyObject *ar */ if (PyInt_CheckExact(result)) { long i_result = PyInt_AS_LONG(result); - Py_DECREF(result); - result = NULL; + Py_CLEAR(result); while(result == NULL) { item = PyIter_Next(iter); if (item == NULL) { @@ -2361,8 +2360,7 @@ builtin_sum(PyObject *self, PyObject *ar if (PyFloat_CheckExact(result)) { double f_result = PyFloat_AS_DOUBLE(result); - Py_DECREF(result); - result = NULL; + Py_CLEAR(result); while(result == NULL) { item = PyIter_Next(iter); if (item == NULL) { @@ -2403,8 +2401,7 @@ builtin_sum(PyObject *self, PyObject *ar if (item == NULL) { /* error, or end-of-sequence */ if (PyErr_Occurred()) { - Py_DECREF(result); - result = NULL; + Py_CLEAR(result); } break; } @@ -2552,8 +2549,7 @@ builtin_zip(PyObject *self, PyObject *ar PyObject *item = PyIter_Next(it); if (!item) { if (PyErr_Occurred()) { - Py_DECREF(ret); - ret = NULL; + Py_CLEAR(ret); } Py_DECREF(next); Py_DECREF(itlist); diff -r 06772ba3d001 Python/errors.c --- a/Python/errors.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Python/errors.c Fri Nov 09 01:59:49 2012 +0100 @@ -30,8 +30,7 @@ PyErr_Restore(PyObject *type, PyObject * if (traceback != NULL && !PyTraceBack_Check(traceback)) { /* XXX Should never happen -- fatal error instead? */ /* Well, it could be None. */ - Py_DECREF(traceback); - traceback = NULL; + Py_CLEAR(traceback); } /* Save these in locals to safeguard against recursive diff -r 06772ba3d001 Python/import.c --- a/Python/import.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Python/import.c Fri Nov 09 01:59:49 2012 +0100 @@ -269,8 +269,7 @@ void void _PyImport_Fini(void) { - Py_XDECREF(extensions); - extensions = NULL; + Py_CLEAR(extensions); PyMem_DEL(_PyImport_Filetab); _PyImport_Filetab = NULL; } @@ -2656,8 +2655,7 @@ import_submodule(PyObject *mod, char *su if (fp) fclose(fp); if (!add_submodule(mod, m, fullname, subname, modules)) { - Py_XDECREF(m); - m = NULL; + Py_CLEAR(m); } PyMem_FREE(buf); } diff -r 06772ba3d001 Python/marshal.c --- a/Python/marshal.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Python/marshal.c Fri Nov 09 01:59:49 2012 +0100 @@ -882,8 +882,7 @@ r_object(RFILE *p) if (!PyErr_Occurred()) PyErr_SetString(PyExc_TypeError, "NULL object in marshal data for tuple"); - Py_DECREF(v); - v = NULL; + Py_CLEAR(v); break; } PyTuple_SET_ITEM(v, (int)i, v2); @@ -909,8 +908,7 @@ r_object(RFILE *p) if (!PyErr_Occurred()) PyErr_SetString(PyExc_TypeError, "NULL object in marshal data for list"); - Py_DECREF(v); - v = NULL; + Py_CLEAR(v); break; } PyList_SET_ITEM(v, (int)i, v2); @@ -936,8 +934,7 @@ r_object(RFILE *p) Py_XDECREF(val); } if (PyErr_Occurred()) { - Py_DECREF(v); - v = NULL; + Py_CLEAR(v); } retval = v; break; @@ -961,8 +958,7 @@ r_object(RFILE *p) if (!PyErr_Occurred()) PyErr_SetString(PyExc_TypeError, "NULL object in marshal data for set"); - Py_DECREF(v); - v = NULL; + Py_CLEAR(v); break; } if (PySet_Add(v, v2) == -1) { diff -r 06772ba3d001 Python/modsupport.c --- a/Python/modsupport.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Python/modsupport.c Fri Nov 09 01:59:49 2012 +0100 @@ -192,8 +192,7 @@ do_mkdict(const char **p_format, va_list } } if (d != NULL && **p_format != endchar) { - Py_DECREF(d); - d = NULL; + Py_CLEAR(d); PyErr_SetString(PyExc_SystemError, "Unmatched paren in format"); } diff -r 06772ba3d001 Python/structmember.c --- a/Python/structmember.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Python/structmember.c Fri Nov 09 01:59:49 2012 +0100 @@ -18,8 +18,7 @@ listmembers(struct memberlist *mlist) PyList_SetItem(v, i, PyString_FromString(mlist[i].name)); if (PyErr_Occurred()) { - Py_DECREF(v); - v = NULL; + Py_CLEAR(v); } else { PyList_Sort(v); diff -r 06772ba3d001 Python/sysmodule.c --- a/Python/sysmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/Python/sysmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -367,8 +367,7 @@ trace_trampoline(PyObject *self, PyFrame result = call_trampoline(tstate, callback, frame, what, arg); if (result == NULL) { PyEval_SetTrace(NULL, NULL); - Py_XDECREF(frame->f_trace); - frame->f_trace = NULL; + Py_CLEAR(frame->f_trace); return -1; } if (result != Py_None) { @@ -990,8 +989,7 @@ list_builtin_module_names(void) Py_DECREF(name); } if (PyList_Sort(list) != 0) { - Py_DECREF(list); - list = NULL; + Py_CLEAR(list); } if (list) { PyObject *v = PyList_AsTuple(list); @@ -1587,8 +1585,7 @@ makeargvobject(int argc, char **argv) PyObject *v = PyString_FromString(argv[i]); #endif if (v == NULL) { - Py_DECREF(av); - av = NULL; + Py_CLEAR(av); break; } PyList_SetItem(av, i, v); diff -r 06772ba3d001 RISCOS/Modules/drawfmodule.c --- a/RISCOS/Modules/drawfmodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/RISCOS/Modules/drawfmodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -611,7 +611,7 @@ static PyObject *PyDrawF_GetAttr(PyDrawF if (list) { PyList_SetItem(list, 0, PyString_FromString("size")); PyList_SetItem(list, 1, PyString_FromString("start")); - if (PyErr_Occurred()) { Py_DECREF(list);list = NULL;} + if (PyErr_Occurred()) { Py_CLEAR(list);} } return list; } diff -r 06772ba3d001 RISCOS/Modules/swimodule.c --- a/RISCOS/Modules/swimodule.c Thu Oct 04 22:52:07 2012 +0300 +++ b/RISCOS/Modules/swimodule.c Fri Nov 09 01:59:49 2012 +0100 @@ -299,7 +299,7 @@ static PyObject *PyBlock_GetAttr(PyBlock { PyList_SetItem(list, 0, PyString_FromString("length")); PyList_SetItem(list, 1, PyString_FromString("start")); PyList_SetItem(list, 2, PyString_FromString("end")); - if (PyErr_Occurred()) { Py_DECREF(list);list = NULL;} + if (PyErr_Occurred()) { Py_CLEAR(list);} } return list; }