diff --git a/Include/object.h b/Include/object.h index 8fe202dd3fd..6481a5b65f1 100644 --- a/Include/object.h +++ b/Include/object.h @@ -833,14 +833,14 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force); * * The safe way is: * - * Py_SETREF(op, op2); + * Py_XSETREF(op, op2); * * That arranges to set `op` to `op2` _before_ decref'ing, so that any code * triggered as a side-effect of `op` getting torn down no longer believes * `op` points to a valid object. */ -#define Py_SETREF(op, op2) \ +#define Py_XSETREF(op, op2) \ do { \ PyObject *_py_tmp = (PyObject *)(op); \ (op) = (op2); \ diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index 9cebaf4dc46..5fd52d99fa6 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -1608,7 +1608,7 @@ DB_associate(DBObject* self, PyObject* args, PyObject* kwargs) /* Save a reference to the callback in the secondary DB. */ Py_XINCREF(callback); - Py_SETREF(secondaryDB->associateCallback, callback); + Py_XSETREF(secondaryDB->associateCallback, callback); secondaryDB->primaryDBType = _DB_get_type(self); /* PyEval_InitThreads is called here due to a quirk in python 1.5 @@ -2498,7 +2498,7 @@ DB_set_private(DBObject* self, PyObject* private_obj) { /* We can set the private field even if db is closed */ Py_INCREF(private_obj); - Py_SETREF(self->private_obj, private_obj); + Py_XSETREF(self->private_obj, private_obj); RETURN_NONE(); } @@ -6997,7 +6997,7 @@ DBEnv_set_private(DBEnvObject* self, PyObject* private_obj) { /* We can set the private field even if dbenv is closed */ Py_INCREF(private_obj); - Py_SETREF(self->private_obj, private_obj); + Py_XSETREF(self->private_obj, private_obj); RETURN_NONE(); } @@ -7251,7 +7251,7 @@ DBEnv_set_event_notify(DBEnvObject* self, PyObject* notifyFunc) } Py_INCREF(notifyFunc); - Py_SETREF(self->event_notifyCallback, notifyFunc); + Py_XSETREF(self->event_notifyCallback, notifyFunc); /* This is to workaround a problem with un-initialized threads (see comment in DB_associate) */ @@ -7410,7 +7410,7 @@ DBEnv_rep_set_transport(DBEnvObject* self, PyObject* args) RETURN_IF_ERR(); Py_INCREF(rep_transport); - Py_SETREF(self->rep_transport, rep_transport); + Py_XSETREF(self->rep_transport, rep_transport); RETURN_NONE(); } diff --git a/Modules/_csv.c b/Modules/_csv.c index 9271413863b..e78ac957f84 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -277,7 +277,7 @@ _set_str(const char *name, PyObject **target, PyObject *src, const char *dflt) } else { Py_INCREF(src); - Py_SETREF(*target, src); + Py_XSETREF(*target, src); } } return 0; @@ -769,7 +769,7 @@ parse_process_char(ReaderObj *self, char c) static int parse_reset(ReaderObj *self) { - Py_SETREF(self->fields, PyList_New(0)); + Py_XSETREF(self->fields, PyList_New(0)); if (self->fields == NULL) return -1; self->field_len = 0; diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 7d66d117f97..7f66d6a85f9 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -424,7 +424,7 @@ StructUnionType_new(PyTypeObject *type, PyObject *args, PyObject *kwds, int isSt Py_DECREF((PyObject *)dict); return NULL; } - Py_SETREF(result->tp_dict, (PyObject *)dict); + Py_XSETREF(result->tp_dict, (PyObject *)dict); dict->format = _ctypes_alloc_format_string(NULL, "B"); if (dict->format == NULL) { Py_DECREF(result); @@ -902,7 +902,7 @@ PyCPointerType_SetProto(StgDictObject *stgdict, PyObject *proto) return -1; } Py_INCREF(proto); - Py_SETREF(stgdict->proto, proto); + Py_XSETREF(stgdict->proto, proto); return 0; } @@ -992,7 +992,7 @@ PyCPointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) Py_DECREF((PyObject *)stgdict); return NULL; } - Py_SETREF(result->tp_dict, (PyObject *)stgdict); + Py_XSETREF(result->tp_dict, (PyObject *)stgdict); return (PyObject *)result; } @@ -1457,7 +1457,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) Py_DECREF((PyObject *)stgdict); return NULL; } - Py_SETREF(result->tp_dict, (PyObject *)stgdict); + Py_XSETREF(result->tp_dict, (PyObject *)stgdict); /* Special case for character arrays. A permanent annoyance: char arrays are also strings! @@ -1880,7 +1880,7 @@ static PyObject *CreateSwappedType(PyTypeObject *type, PyObject *args, PyObject Py_DECREF((PyObject *)stgdict); return NULL; } - Py_SETREF(result->tp_dict, (PyObject *)stgdict); + Py_XSETREF(result->tp_dict, (PyObject *)stgdict); return (PyObject *)result; } @@ -2388,7 +2388,7 @@ PyCFuncPtrType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) Py_DECREF((PyObject *)stgdict); return NULL; } - Py_SETREF(result->tp_dict, (PyObject *)stgdict); + Py_XSETREF(result->tp_dict, (PyObject *)stgdict); if (-1 == make_funcptrtype_dict(stgdict)) { Py_DECREF(result); @@ -2530,7 +2530,7 @@ KeepRef(CDataObject *target, Py_ssize_t index, PyObject *keep) } ob = PyCData_GetContainer(target); if (ob->b_objects == NULL || !PyDict_CheckExact(ob->b_objects)) { - Py_SETREF(ob->b_objects, keep); /* refcount consumed */ + Py_XSETREF(ob->b_objects, keep); /* refcount consumed */ return 0; } key = unique_key(target, index); @@ -3053,7 +3053,7 @@ PyCFuncPtr_set_errcheck(PyCFuncPtrObject *self, PyObject *ob) return -1; } Py_XINCREF(ob); - Py_SETREF(self->errcheck, ob); + Py_XSETREF(self->errcheck, ob); return 0; } @@ -3082,8 +3082,8 @@ PyCFuncPtr_set_restype(PyCFuncPtrObject *self, PyObject *ob) return -1; } Py_INCREF(ob); - Py_SETREF(self->restype, ob); - Py_SETREF(self->checker, PyObject_GetAttrString(ob, "_check_retval_")); + Py_XSETREF(self->restype, ob); + Py_XSETREF(self->checker, PyObject_GetAttrString(ob, "_check_retval_")); if (self->checker == NULL) PyErr_Clear(); return 0; @@ -3120,9 +3120,9 @@ PyCFuncPtr_set_argtypes(PyCFuncPtrObject *self, PyObject *ob) converters = converters_from_argtypes(ob); if (!converters) return -1; - Py_SETREF(self->converters, converters); + Py_XSETREF(self->converters, converters); Py_INCREF(ob); - Py_SETREF(self->argtypes, ob); + Py_XSETREF(self->argtypes, ob); } return 0; } diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index d61281ed06b..dbc0f5332a7 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -284,7 +284,7 @@ PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args) return NULL; } Py_INCREF(temp); - Py_SETREF(po->wo, temp); + Py_XSETREF(po->wo, temp); Py_INCREF(Py_None); return Py_None; } diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index a035c579202..793d4c73c63 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1574,7 +1574,7 @@ element_setattr(ElementObject* self, const char* name, PyObject* value) if (strcmp(name, "tag") == 0) { Py_INCREF(value); - Py_SETREF(self->tag, value); + Py_XSETREF(self->tag, value); } else if (strcmp(name, "text") == 0) { Py_DECREF(JOIN_OBJ(self->text)); self->text = value; @@ -1587,7 +1587,7 @@ element_setattr(ElementObject* self, const char* name, PyObject* value) if (!self->extra) element_new_extra(self, NULL); Py_INCREF(value); - Py_SETREF(self->extra->attrib, value); + Py_XSETREF(self->extra->attrib, value); } else { PyErr_SetString(PyExc_AttributeError, name); return -1; @@ -1799,10 +1799,10 @@ treebuilder_handle_start(TreeBuilderObject* self, PyObject* tag, self->index++; Py_INCREF(node); - Py_SETREF(self->this, (ElementObject*) node); + Py_XSETREF(self->this, (ElementObject*) node); Py_INCREF(node); - Py_SETREF(self->last, (ElementObject*) node); + Py_XSETREF(self->last, (ElementObject*) node); if (treebuilder_append_event(self, self->start_event_obj, node) < 0) goto error; @@ -2744,7 +2744,7 @@ xmlparser_setevents(XMLParserObject* self, PyObject* args) target = (TreeBuilderObject*) self->target; Py_INCREF(events); - Py_SETREF(target->events, events); + Py_XSETREF(target->events, events); /* clear out existing events */ Py_CLEAR(target->start_event_obj); @@ -2769,18 +2769,18 @@ xmlparser_setevents(XMLParserObject* self, PyObject* args) Py_INCREF(item); event = PyString_AS_STRING(item); if (strcmp(event, "start") == 0) { - Py_SETREF(target->start_event_obj, item); + Py_XSETREF(target->start_event_obj, item); } else if (strcmp(event, "end") == 0) { - Py_SETREF(target->end_event_obj, item); + Py_XSETREF(target->end_event_obj, item); } else if (strcmp(event, "start-ns") == 0) { - Py_SETREF(target->start_ns_event_obj, item); + Py_XSETREF(target->start_ns_event_obj, item); EXPAT(SetNamespaceDeclHandler)( self->parser, (XML_StartNamespaceDeclHandler) expat_start_ns_handler, (XML_EndNamespaceDeclHandler) expat_end_ns_handler ); } else if (strcmp(event, "end-ns") == 0) { - Py_SETREF(target->end_ns_event_obj, item); + Py_XSETREF(target->end_ns_event_obj, item); EXPAT(SetNamespaceDeclHandler)( self->parser, (XML_StartNamespaceDeclHandler) expat_start_ns_handler, diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 2ad556d93a3..b2cfd753944 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -320,10 +320,10 @@ partial_setstate(partialobject *pto, PyObject *state) else Py_INCREF(dict); - Py_SETREF(pto->fn, fn); - Py_SETREF(pto->args, fnargs); - Py_SETREF(pto->kw, kw); - Py_SETREF(pto->dict, dict); + Py_XSETREF(pto->fn, fn); + Py_XSETREF(pto->args, fnargs); + Py_XSETREF(pto->kw, kw); + Py_XSETREF(pto->dict, dict); Py_RETURN_NONE; } diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 9b2e5b26f17..600bf8adb43 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1028,7 +1028,7 @@ found: Py_CLEAR(res); goto end; } - Py_SETREF(res, _PyBytes_Join(_PyIO_empty_bytes, chunks)); + Py_XSETREF(res, _PyBytes_Join(_PyIO_empty_bytes, chunks)); end: LEAVE_BUFFERED(self) @@ -1264,7 +1264,7 @@ bufferedreader_init(buffered *self, PyObject *args, PyObject *kwds) return -1; Py_INCREF(raw); - Py_SETREF(self->raw, raw); + Py_XSETREF(self->raw, raw); self->buffer_size = buffer_size; self->readable = 1; self->writable = 0; @@ -1686,7 +1686,7 @@ bufferedwriter_init(buffered *self, PyObject *args, PyObject *kwds) return -1; Py_INCREF(raw); - Py_SETREF(self->raw, raw); + Py_XSETREF(self->raw, raw); self->readable = 0; self->writable = 1; @@ -2342,7 +2342,7 @@ bufferedrandom_init(buffered *self, PyObject *args, PyObject *kwds) return -1; Py_INCREF(raw); - Py_SETREF(self->raw, raw); + Py_XSETREF(self->raw, raw); self->buffer_size = buffer_size; self->readable = 1; self->writable = 1; diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index bb4c5efae8b..38bb0d8eff8 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -966,7 +966,7 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds) "Oi", self->decoder, (int)self->readtranslate); if (incrementalDecoder == NULL) goto error; - Py_SETREF(self->decoder, incrementalDecoder); + Py_XSETREF(self->decoder, incrementalDecoder); } } @@ -1346,7 +1346,7 @@ textiowrapper_write(textio *self, PyObject *args) static void textiowrapper_set_decoded_chars(textio *self, PyObject *chars) { - Py_SETREF(self->decoded_chars, chars); + Py_XSETREF(self->decoded_chars, chars); self->decoded_chars_used = 0; } @@ -1475,7 +1475,7 @@ textiowrapper_read_chunk(textio *self) goto fail; } Py_DECREF(dec_buffer); - Py_SETREF(self->snapshot, Py_BuildValue("NN", dec_flags, next_input)); + Py_XSETREF(self->snapshot, Py_BuildValue("NN", dec_flags, next_input)); } Py_DECREF(input_chunk); @@ -1575,7 +1575,7 @@ textiowrapper_read(textio *self, PyObject *args) if (chunks != NULL) { if (result != NULL && PyList_Append(chunks, result) < 0) goto fail; - Py_SETREF(result, PyUnicode_Join(_PyIO_empty_str, chunks)); + Py_XSETREF(result, PyUnicode_Join(_PyIO_empty_str, chunks)); if (result == NULL) goto fail; Py_CLEAR(chunks); @@ -1832,7 +1832,7 @@ _textiowrapper_readline(textio *self, Py_ssize_t limit) if (chunks != NULL) { if (line != NULL && PyList_Append(chunks, line) < 0) goto error; - Py_SETREF(line, PyUnicode_Join(_PyIO_empty_str, chunks)); + Py_XSETREF(line, PyUnicode_Join(_PyIO_empty_str, chunks)); if (line == NULL) goto error; Py_DECREF(chunks); diff --git a/Modules/_json.c b/Modules/_json.c index fede6b14a17..9c8f66ce110 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -1717,7 +1717,7 @@ scanner_init(PyObject *self, PyObject *args, PyObject *kwds) } else if (PyUnicode_Check(s->encoding)) { PyObject *tmp = PyUnicode_AsEncodedString(s->encoding, NULL, NULL); - Py_SETREF(s->encoding, tmp); + Py_XSETREF(s->encoding, tmp); } if (s->encoding == NULL) goto bail; diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index c67d10c2f3b..9ced405acaf 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -228,7 +228,7 @@ void pysqlite_flush_statement_cache(pysqlite_Connection* self) node = node->next; } - Py_SETREF(self->statement_cache, + Py_XSETREF(self->statement_cache, (pysqlite_Cache *)PyObject_CallFunction((PyObject *)&pysqlite_CacheType, "O", self)); Py_DECREF(self); self->statement_cache->decref_factory = 0; @@ -347,7 +347,7 @@ PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, if (cursor && self->row_factory != Py_None) { Py_INCREF(self->row_factory); - Py_SETREF(((pysqlite_Cursor *)cursor)->row_factory, self->row_factory); + Py_XSETREF(((pysqlite_Cursor *)cursor)->row_factory, self->row_factory); } return cursor; @@ -815,7 +815,7 @@ static void _pysqlite_drop_unused_statement_references(pysqlite_Connection* self } } - Py_SETREF(self->statements, new_list); + Py_XSETREF(self->statements, new_list); } static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self) @@ -846,7 +846,7 @@ static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self) } } - Py_SETREF(self->cursors, new_list); + Py_XSETREF(self->cursors, new_list); } PyObject* pysqlite_connection_create_function(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 3d5b8f396ae..b3ec8f253c9 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -172,7 +172,7 @@ int pysqlite_build_row_cast_map(pysqlite_Cursor* self) return 0; } - Py_SETREF(self->row_cast_map, PyList_New(0)); + Py_XSETREF(self->row_cast_map, PyList_New(0)); for (i = 0; i < sqlite3_column_count(self->statement->st); i++) { converter = NULL; @@ -544,7 +544,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* /* reset description and rowcount */ Py_INCREF(Py_None); - Py_SETREF(self->description, Py_None); + Py_XSETREF(self->description, Py_None); self->rowcount = -1L; func_args = PyTuple_New(1); @@ -560,7 +560,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* (void)pysqlite_statement_reset(self->statement); } - Py_SETREF(self->statement, + Py_XSETREF(self->statement, (pysqlite_Statement *)pysqlite_cache_get(self->connection->statement_cache, func_args)); Py_DECREF(func_args); @@ -569,7 +569,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* } if (self->statement->in_use) { - Py_SETREF(self->statement, + Py_XSETREF(self->statement, PyObject_New(pysqlite_Statement, &pysqlite_StatementType)); if (!self->statement) { goto error; @@ -681,7 +681,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* numcols = sqlite3_column_count(self->statement->st); Py_END_ALLOW_THREADS - Py_SETREF(self->description, PyTuple_New(numcols)); + Py_XSETREF(self->description, PyTuple_New(numcols)); if (!self->description) { goto error; } diff --git a/Modules/_sre.c b/Modules/_sre.c index 829fb6bdcc8..485020e127c 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -2054,7 +2054,7 @@ deepcopy(PyObject** object, PyObject* memo) if (!copy) return 0; - Py_SETREF(*object, copy); + Py_XSETREF(*object, copy); return 1; /* success */ } diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 23d4d5ceab2..a44414b1888 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1467,7 +1467,7 @@ static int PySSL_set_context(PySSLSocket *self, PyObject *value, return -1; #else Py_INCREF(value); - Py_SETREF(self->ctx, (PySSLContext *)value); + Py_XSETREF(self->ctx, (PySSLContext *)value); SSL_set_SSL_CTX(self->ssl, self->ctx->ctx); #endif } else { diff --git a/Modules/_struct.c b/Modules/_struct.c index 196a0938dde..50fb1385bfb 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1377,13 +1377,13 @@ s_init(PyObject *self, PyObject *args, PyObject *kwds) if (PyString_Check(o_format)) { Py_INCREF(o_format); - Py_SETREF(soself->s_format, o_format); + Py_XSETREF(soself->s_format, o_format); } else if (PyUnicode_Check(o_format)) { PyObject *str = PyUnicode_AsEncodedString(o_format, "ascii", NULL); if (str == NULL) return -1; - Py_SETREF(soself->s_format, str); + Py_XSETREF(soself->s_format, str); } else { PyErr_Format(PyExc_TypeError, diff --git a/Modules/bz2module.c b/Modules/bz2module.c index fe417c5ffa0..c33e03ca223 100644 --- a/Modules/bz2module.c +++ b/Modules/bz2module.c @@ -1953,7 +1953,7 @@ BZ2Decomp_decompress(BZ2DecompObject *self, PyObject *args) self->running = 0; input_left += bzs->avail_in; if (input_left != 0) { - Py_SETREF(self->unused_data, + Py_XSETREF(self->unused_data, PyString_FromStringAndSize(bzs->next_in, input_left)); if (self->unused_data == NULL) goto error; diff --git a/Modules/cPickle.c b/Modules/cPickle.c index a00108e1048..cab7ca862e1 100644 --- a/Modules/cPickle.c +++ b/Modules/cPickle.c @@ -689,7 +689,7 @@ read_other(Unpicklerobject *self, char **s, Py_ssize_t n) } if (! str) return -1; - Py_SETREF(self->last_string, str); + Py_XSETREF(self->last_string, str); if (! (*s = PyString_AsString(str))) return -1; @@ -715,7 +715,7 @@ readline_other(Unpicklerobject *self, char **s) if ((str_size = PyString_Size(str)) < 0) return -1; - Py_SETREF(self->last_string, str); + Py_XSETREF(self->last_string, str); if (! (*s = PyString_AsString(str))) return -1; @@ -3227,7 +3227,7 @@ Pickler_set_pers_func(Picklerobject *p, PyObject *v) return -1; } Py_INCREF(v); - Py_SETREF(p->pers_func, v); + Py_XSETREF(p->pers_func, v); return 0; } @@ -3240,7 +3240,7 @@ Pickler_set_inst_pers_func(Picklerobject *p, PyObject *v) return -1; } Py_INCREF(v); - Py_SETREF(p->inst_pers_func, v); + Py_XSETREF(p->inst_pers_func, v); return 0; } @@ -3267,7 +3267,7 @@ Pickler_set_memo(Picklerobject *p, PyObject *v) return -1; } Py_INCREF(v); - Py_SETREF(p->memo, v); + Py_XSETREF(p->memo, v); return 0; } @@ -5663,13 +5663,13 @@ Unpickler_setattr(Unpicklerobject *self, char *name, PyObject *value) if (!strcmp(name, "persistent_load")) { Py_XINCREF(value); - Py_SETREF(self->pers_func, value); + Py_XSETREF(self->pers_func, value); return 0; } if (!strcmp(name, "find_global")) { Py_XINCREF(value); - Py_SETREF(self->find_class, value); + Py_XSETREF(self->find_class, value); return 0; } @@ -5686,7 +5686,7 @@ Unpickler_setattr(Unpicklerobject *self, char *name, PyObject *value) return -1; } Py_INCREF(value); - Py_SETREF(self->memo, value); + Py_XSETREF(self->memo, value); return 0; } diff --git a/Modules/cdmodule.c b/Modules/cdmodule.c index 9ef87277679..ddb2996e90b 100644 --- a/Modules/cdmodule.c +++ b/Modules/cdmodule.c @@ -629,9 +629,9 @@ CD_addcallback(cdparserobject *self, PyObject *args) (void *) self); #endif Py_INCREF(func); - Py_SETREF(self->ob_cdcallbacks[type].ob_cdcallback, func); + Py_XSETREF(self->ob_cdcallbacks[type].ob_cdcallback, func); Py_INCREF(funcarg); - Py_SETREF(self->ob_cdcallbacks[type].ob_cdcallbackarg, funcarg); + Py_XSETREF(self->ob_cdcallbacks[type].ob_cdcallbackarg, funcarg); /* if (type == cd_audio) { diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 68285b82f6c..24933211f98 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -492,7 +492,7 @@ tee_next(teeobject *to) link = teedataobject_jumplink(to->dataobj); if (link == NULL) return NULL; - Py_SETREF(to->dataobj, (teedataobject *)link); + Py_XSETREF(to->dataobj, (teedataobject *)link); to->index = 0; } value = teedataobject_getitem(to->dataobj, to->index); diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index c0e17f3a2e5..81674c80f57 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -621,7 +621,7 @@ initsignal(void) if (Handlers[SIGINT].func == DefaultHandler) { /* Install default int handler */ Py_INCREF(IntHandler); - Py_SETREF(Handlers[SIGINT].func, IntHandler); + Py_XSETREF(Handlers[SIGINT].func, IntHandler); old_siginthandler = PyOS_setsig(SIGINT, signal_handler); } diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index 8c7916eb015..f3282b2eeb8 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -491,7 +491,7 @@ save_unconsumed_input(compobject *self, int err) PyString_AS_STRING(self->unused_data), old_size); Py_MEMCPY(PyString_AS_STRING(new_data) + old_size, self->zst.next_in, self->zst.avail_in); - Py_SETREF(self->unused_data, new_data); + Py_XSETREF(self->unused_data, new_data); self->zst.avail_in = 0; } } @@ -503,7 +503,7 @@ save_unconsumed_input(compobject *self, int err) (char *)self->zst.next_in, self->zst.avail_in); if (new_data == NULL) return -1; - Py_SETREF(self->unconsumed_tail, new_data); + Py_XSETREF(self->unconsumed_tail, new_data); } return 0; } @@ -731,9 +731,9 @@ PyZlib_copy(compobject *self) } Py_INCREF(self->unused_data); - Py_SETREF(retval->unused_data, self->unused_data); + Py_XSETREF(retval->unused_data, self->unused_data); Py_INCREF(self->unconsumed_tail); - Py_SETREF(retval->unconsumed_tail, self->unconsumed_tail); + Py_XSETREF(retval->unconsumed_tail, self->unconsumed_tail); /* Mark it as being initialized */ retval->is_initialised = 1; @@ -780,9 +780,9 @@ PyZlib_uncopy(compobject *self) } Py_INCREF(self->unused_data); - Py_SETREF(retval->unused_data, self->unused_data); + Py_XSETREF(retval->unused_data, self->unused_data); Py_INCREF(self->unconsumed_tail); - Py_SETREF(retval->unconsumed_tail, self->unconsumed_tail); + Py_XSETREF(retval->unconsumed_tail, self->unconsumed_tail); /* Mark it as being initialized */ retval->is_initialised = 1; diff --git a/Objects/descrobject.c b/Objects/descrobject.c index c7271ef9d6a..8d6e6e3a246 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1332,7 +1332,7 @@ property_init(PyObject *self, PyObject *args, PyObject *kwds) PyObject *get_doc = PyObject_GetAttrString(get, "__doc__"); if (get_doc) { if (Py_TYPE(self) == &PyProperty_Type) { - Py_SETREF(prop->prop_doc, get_doc); + Py_XSETREF(prop->prop_doc, get_doc); } else { /* If this is a property subclass, put __doc__ diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 8f2c7a6789f..8906f1a786d 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -59,11 +59,11 @@ BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds) return -1; Py_INCREF(args); - Py_SETREF(self->args, args); + Py_XSETREF(self->args, args); if (PyTuple_GET_SIZE(self->args) == 1) { Py_INCREF(PyTuple_GET_ITEM(self->args, 0)); - Py_SETREF(self->message, PyTuple_GET_ITEM(self->args, 0)); + Py_XSETREF(self->message, PyTuple_GET_ITEM(self->args, 0)); } return 0; } @@ -279,7 +279,7 @@ BaseException_set_dict(PyBaseExceptionObject *self, PyObject *val) return -1; } Py_INCREF(val); - Py_SETREF(self->dict, val); + Py_XSETREF(self->dict, val); return 0; } @@ -305,7 +305,7 @@ BaseException_set_args(PyBaseExceptionObject *self, PyObject *val) seq = PySequence_Tuple(val); if (!seq) return -1; - Py_SETREF(self->args, seq); + Py_XSETREF(self->args, seq); return 0; } @@ -519,11 +519,11 @@ SystemExit_init(PySystemExitObject *self, PyObject *args, PyObject *kwds) return 0; if (size == 1) { Py_INCREF(PyTuple_GET_ITEM(args, 0)); - Py_SETREF(self->code, PyTuple_GET_ITEM(args, 0)); + Py_XSETREF(self->code, PyTuple_GET_ITEM(args, 0)); } else { /* size > 1 */ Py_INCREF(args); - Py_SETREF(self->code, args); + Py_XSETREF(self->code, args); } return 0; } @@ -608,21 +608,21 @@ EnvironmentError_init(PyEnvironmentErrorObject *self, PyObject *args, return -1; } Py_INCREF(myerrno); - Py_SETREF(self->myerrno, myerrno); + Py_XSETREF(self->myerrno, myerrno); Py_INCREF(strerror); - Py_SETREF(self->strerror, strerror); + Py_XSETREF(self->strerror, strerror); /* self->filename will remain Py_None otherwise */ if (filename != NULL) { Py_INCREF(filename); - Py_SETREF(self->filename, filename); + Py_XSETREF(self->filename, filename); subslice = PyTuple_GetSlice(args, 0, 2); if (!subslice) return -1; - Py_SETREF(self->args, subslice); + Py_XSETREF(self->args, subslice); } return 0; } @@ -873,7 +873,7 @@ WindowsError_init(PyWindowsErrorObject *self, PyObject *args, PyObject *kwds) return -1; posix_errno = winerror_to_errno(errcode); - Py_SETREF(self->winerror, self->myerrno); + Py_XSETREF(self->winerror, self->myerrno); o_errcode = PyInt_FromLong(posix_errno); if (!o_errcode) @@ -1059,7 +1059,7 @@ SyntaxError_init(PySyntaxErrorObject *self, PyObject *args, PyObject *kwds) if (lenargs >= 1) { Py_INCREF(PyTuple_GET_ITEM(args, 0)); - Py_SETREF(self->msg, PyTuple_GET_ITEM(args, 0)); + Py_XSETREF(self->msg, PyTuple_GET_ITEM(args, 0)); } if (lenargs == 2) { info = PyTuple_GET_ITEM(args, 1); @@ -1075,16 +1075,16 @@ SyntaxError_init(PySyntaxErrorObject *self, PyObject *args, PyObject *kwds) } Py_INCREF(PyTuple_GET_ITEM(info, 0)); - Py_SETREF(self->filename, PyTuple_GET_ITEM(info, 0)); + Py_XSETREF(self->filename, PyTuple_GET_ITEM(info, 0)); Py_INCREF(PyTuple_GET_ITEM(info, 1)); - Py_SETREF(self->lineno, PyTuple_GET_ITEM(info, 1)); + Py_XSETREF(self->lineno, PyTuple_GET_ITEM(info, 1)); Py_INCREF(PyTuple_GET_ITEM(info, 2)); - Py_SETREF(self->offset, PyTuple_GET_ITEM(info, 2)); + Py_XSETREF(self->offset, PyTuple_GET_ITEM(info, 2)); Py_INCREF(PyTuple_GET_ITEM(info, 3)); - Py_SETREF(self->text, PyTuple_GET_ITEM(info, 3)); + Py_XSETREF(self->text, PyTuple_GET_ITEM(info, 3)); Py_DECREF(info); } @@ -1317,7 +1317,7 @@ set_string(PyObject **attr, const char *value) PyObject *obj = PyString_FromString(value); if (!obj) return -1; - Py_SETREF(*attr, obj); + Py_XSETREF(*attr, obj); return 0; } diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 9ae068cfc59..e4f7fc404dd 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -574,8 +574,8 @@ PyFile_SetEncodingAndErrors(PyObject *f, const char *enc, char* errors) oerrors = Py_None; Py_INCREF(Py_None); } - Py_SETREF(file->f_encoding, str); - Py_SETREF(file->f_errors, oerrors); + Py_XSETREF(file->f_encoding, str); + Py_XSETREF(file->f_errors, oerrors); return 1; } diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 6ca390b34b3..4ba3e84b0f2 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -859,7 +859,7 @@ dict_to_map(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values, } } else if (values[j] != value) { Py_XINCREF(value); - Py_SETREF(values[j], value); + Py_XSETREF(values[j], value); } Py_XDECREF(value); } diff --git a/Objects/funcobject.c b/Objects/funcobject.c index da54069d52e..26369626f95 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -116,7 +116,7 @@ PyFunction_SetDefaults(PyObject *op, PyObject *defaults) PyErr_SetString(PyExc_SystemError, "non-tuple default args"); return -1; } - Py_SETREF(((PyFunctionObject *)op)->func_defaults, defaults); + Py_XSETREF(((PyFunctionObject *)op)->func_defaults, defaults); return 0; } @@ -148,7 +148,7 @@ PyFunction_SetClosure(PyObject *op, PyObject *closure) closure->ob_type->tp_name); return -1; } - Py_SETREF(((PyFunctionObject *)op)->func_closure, closure); + Py_XSETREF(((PyFunctionObject *)op)->func_closure, closure); return 0; } @@ -428,7 +428,7 @@ func_new(PyTypeObject* type, PyObject* args, PyObject* kw) if (name != Py_None) { Py_INCREF(name); - Py_SETREF(newfunc->func_name, name); + Py_XSETREF(newfunc->func_name, name); } if (defaults != Py_None) { Py_INCREF(defaults); diff --git a/Objects/stringobject.c b/Objects/stringobject.c index f585ffc7282..faaa11125cd 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -3865,7 +3865,7 @@ PyString_Concat(register PyObject **pv, register PyObject *w) return; } v = string_concat((PyStringObject *) *pv, w); - Py_SETREF(*pv, v); + Py_XSETREF(*pv, v); } void @@ -4750,7 +4750,7 @@ PyString_InternInPlace(PyObject **p) t = PyDict_GetItem(interned, (PyObject *)s); if (t) { Py_INCREF(t); - Py_SETREF(*p, t); + Py_XSETREF(*p, t); return; } diff --git a/Objects/typeobject.c b/Objects/typeobject.c index a5f3997ee9a..b186623fe78 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -188,7 +188,7 @@ assign_version_tag(PyTypeObject *type) for (i = 0; i < (1 << MCACHE_SIZE_EXP); i++) { method_cache[i].value = NULL; Py_INCREF(Py_None); - Py_SETREF(method_cache[i].name, Py_None); + Py_XSETREF(method_cache[i].name, Py_None); } /* mark all version tags as invalid */ PyType_Modified(&PyBaseObject_Type); diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 9f503bde63e..454451eb671 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -436,7 +436,7 @@ int _PyUnicode_Resize(PyUnicodeObject **unicode, Py_ssize_t length) return -1; Py_UNICODE_COPY(w->str, v->str, length < v->length ? length : v->length); - Py_SETREF(*unicode, w); + Py_XSETREF(*unicode, w); return 0; } diff --git a/Python/_warnings.c b/Python/_warnings.c index 8e8c0cceb31..932f2f8d13d 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -528,7 +528,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno, goto handle_error; } else if (!is_true) { - Py_SETREF(*filename, PyString_FromString("__main__")); + Py_XSETREF(*filename, PyString_FromString("__main__")); if (*filename == NULL) goto handle_error; } diff --git a/Python/ceval.c b/Python/ceval.c index 6e5e27280e9..e56e9574900 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4360,7 +4360,7 @@ call_function(PyObject ***pp_stack, int oparg Py_INCREF(self); func = PyMethod_GET_FUNCTION(func); Py_INCREF(func); - Py_SETREF(*pfunc, self); + Py_XSETREF(*pfunc, self); na++; n++; } else diff --git a/Python/compile.c b/Python/compile.c index bad1f509b05..51f2874b947 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1415,7 +1415,7 @@ compiler_class(struct compiler *c, stmt_ty s) s->lineno)) return 0; Py_INCREF(s->v.ClassDef.name); - Py_SETREF(c->u->u_private, s->v.ClassDef.name); + Py_XSETREF(c->u->u_private, s->v.ClassDef.name); str = PyString_InternFromString("__name__"); if (!str || !compiler_nameop(c, str, Load)) { Py_XDECREF(str); diff --git a/Python/errors.c b/Python/errors.c index d823e1397cc..466a2534dd6 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -229,9 +229,9 @@ finally: --tstate->recursion_depth; /* throw away the old exception and use the recursion error instead */ Py_INCREF(PyExc_RuntimeError); - Py_SETREF(*exc, PyExc_RuntimeError); + Py_XSETREF(*exc, PyExc_RuntimeError); Py_INCREF(PyExc_RecursionErrorInst); - Py_SETREF(*val, PyExc_RecursionErrorInst); + Py_XSETREF(*val, PyExc_RecursionErrorInst); /* just keeping the old traceback */ return; }