Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREF
in places where Py_DECREF was used.
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index 5fd52d9..a319333 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -2498,7 +2498,7 @@
{
/* We can set the private field even if db is closed */
Py_INCREF(private_obj);
- Py_XSETREF(self->private_obj, private_obj);
+ Py_SETREF(self->private_obj, private_obj);
RETURN_NONE();
}
@@ -6997,7 +6997,7 @@
{
/* We can set the private field even if dbenv is closed */
Py_INCREF(private_obj);
- Py_XSETREF(self->private_obj, private_obj);
+ Py_SETREF(self->private_obj, private_obj);
RETURN_NONE();
}
@@ -7410,7 +7410,7 @@
RETURN_IF_ERR();
Py_INCREF(rep_transport);
- Py_XSETREF(self->rep_transport, rep_transport);
+ Py_SETREF(self->rep_transport, rep_transport);
RETURN_NONE();
}
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 7f66d6a..65c55cb 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -424,7 +424,7 @@
Py_DECREF((PyObject *)dict);
return NULL;
}
- Py_XSETREF(result->tp_dict, (PyObject *)dict);
+ Py_SETREF(result->tp_dict, (PyObject *)dict);
dict->format = _ctypes_alloc_format_string(NULL, "B");
if (dict->format == NULL) {
Py_DECREF(result);
@@ -992,7 +992,7 @@
Py_DECREF((PyObject *)stgdict);
return NULL;
}
- Py_XSETREF(result->tp_dict, (PyObject *)stgdict);
+ Py_SETREF(result->tp_dict, (PyObject *)stgdict);
return (PyObject *)result;
}
@@ -1457,7 +1457,7 @@
Py_DECREF((PyObject *)stgdict);
return NULL;
}
- Py_XSETREF(result->tp_dict, (PyObject *)stgdict);
+ Py_SETREF(result->tp_dict, (PyObject *)stgdict);
/* Special case for character arrays.
A permanent annoyance: char arrays are also strings!
@@ -1880,7 +1880,7 @@
Py_DECREF((PyObject *)stgdict);
return NULL;
}
- Py_XSETREF(result->tp_dict, (PyObject *)stgdict);
+ Py_SETREF(result->tp_dict, (PyObject *)stgdict);
return (PyObject *)result;
}
@@ -2388,7 +2388,7 @@
Py_DECREF((PyObject *)stgdict);
return NULL;
}
- Py_XSETREF(result->tp_dict, (PyObject *)stgdict);
+ Py_SETREF(result->tp_dict, (PyObject *)stgdict);
if (-1 == make_funcptrtype_dict(stgdict)) {
Py_DECREF(result);
diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c
index dbc0f53..d61281e 100644
--- a/Modules/_curses_panel.c
+++ b/Modules/_curses_panel.c
@@ -284,7 +284,7 @@
return NULL;
}
Py_INCREF(temp);
- Py_XSETREF(po->wo, temp);
+ Py_SETREF(po->wo, temp);
Py_INCREF(Py_None);
return Py_None;
}
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 793d4c7..0d16a69 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -1574,7 +1574,7 @@
if (strcmp(name, "tag") == 0) {
Py_INCREF(value);
- Py_XSETREF(self->tag, value);
+ Py_SETREF(self->tag, value);
} else if (strcmp(name, "text") == 0) {
Py_DECREF(JOIN_OBJ(self->text));
self->text = value;
@@ -1587,7 +1587,7 @@
if (!self->extra)
element_new_extra(self, NULL);
Py_INCREF(value);
- Py_XSETREF(self->extra->attrib, value);
+ Py_SETREF(self->extra->attrib, value);
} else {
PyErr_SetString(PyExc_AttributeError, name);
return -1;
@@ -1799,10 +1799,10 @@
self->index++;
Py_INCREF(node);
- Py_XSETREF(self->this, (ElementObject*) node);
+ Py_SETREF(self->this, (ElementObject*) node);
Py_INCREF(node);
- Py_XSETREF(self->last, (ElementObject*) node);
+ Py_SETREF(self->last, (ElementObject*) node);
if (treebuilder_append_event(self, self->start_event_obj, node) < 0)
goto error;
diff --git a/Modules/_json.c b/Modules/_json.c
index 9c8f66c..fede6b1 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -1717,7 +1717,7 @@
}
else if (PyUnicode_Check(s->encoding)) {
PyObject *tmp = PyUnicode_AsEncodedString(s->encoding, NULL, NULL);
- Py_XSETREF(s->encoding, tmp);
+ Py_SETREF(s->encoding, tmp);
}
if (s->encoding == NULL)
goto bail;
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 9ced405..6b0e3c6 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -228,7 +228,7 @@
node = node->next;
}
- Py_XSETREF(self->statement_cache,
+ Py_SETREF(self->statement_cache,
(pysqlite_Cache *)PyObject_CallFunction((PyObject *)&pysqlite_CacheType, "O", self));
Py_DECREF(self);
self->statement_cache->decref_factory = 0;
@@ -815,7 +815,7 @@
}
}
- Py_XSETREF(self->statements, new_list);
+ Py_SETREF(self->statements, new_list);
}
static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self)
@@ -846,7 +846,7 @@
}
}
- Py_XSETREF(self->cursors, new_list);
+ Py_SETREF(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 b3ec8f2..f2b48ff 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -544,7 +544,7 @@
/* reset description and rowcount */
Py_INCREF(Py_None);
- Py_XSETREF(self->description, Py_None);
+ Py_SETREF(self->description, Py_None);
self->rowcount = -1L;
func_args = PyTuple_New(1);
@@ -569,7 +569,7 @@
}
if (self->statement->in_use) {
- Py_XSETREF(self->statement,
+ Py_SETREF(self->statement,
PyObject_New(pysqlite_Statement, &pysqlite_StatementType));
if (!self->statement) {
goto error;
@@ -681,7 +681,7 @@
numcols = sqlite3_column_count(self->statement->st);
Py_END_ALLOW_THREADS
- Py_XSETREF(self->description, PyTuple_New(numcols));
+ Py_SETREF(self->description, PyTuple_New(numcols));
if (!self->description) {
goto error;
}
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 485020e..829fb6b 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -2054,7 +2054,7 @@
if (!copy)
return 0;
- Py_XSETREF(*object, copy);
+ Py_SETREF(*object, copy);
return 1; /* success */
}
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index a44414b..23d4d5c 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -1467,7 +1467,7 @@
return -1;
#else
Py_INCREF(value);
- Py_XSETREF(self->ctx, (PySSLContext *)value);
+ Py_SETREF(self->ctx, (PySSLContext *)value);
SSL_set_SSL_CTX(self->ssl, self->ctx->ctx);
#endif
} else {
diff --git a/Modules/bz2module.c b/Modules/bz2module.c
index c33e03c..fe417c5 100644
--- a/Modules/bz2module.c
+++ b/Modules/bz2module.c
@@ -1953,7 +1953,7 @@
self->running = 0;
input_left += bzs->avail_in;
if (input_left != 0) {
- Py_XSETREF(self->unused_data,
+ Py_SETREF(self->unused_data,
PyString_FromStringAndSize(bzs->next_in, input_left));
if (self->unused_data == NULL)
goto error;
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index 2493321..68285b8 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -492,7 +492,7 @@
link = teedataobject_jumplink(to->dataobj);
if (link == NULL)
return NULL;
- Py_XSETREF(to->dataobj, (teedataobject *)link);
+ Py_SETREF(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 81674c8..c0e17f3 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -621,7 +621,7 @@
if (Handlers[SIGINT].func == DefaultHandler) {
/* Install default int handler */
Py_INCREF(IntHandler);
- Py_XSETREF(Handlers[SIGINT].func, IntHandler);
+ Py_SETREF(Handlers[SIGINT].func, IntHandler);
old_siginthandler = PyOS_setsig(SIGINT, signal_handler);
}
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index f3282b2..799e7df 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -491,7 +491,7 @@
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_XSETREF(self->unused_data, new_data);
+ Py_SETREF(self->unused_data, new_data);
self->zst.avail_in = 0;
}
}
@@ -503,7 +503,7 @@
(char *)self->zst.next_in, self->zst.avail_in);
if (new_data == NULL)
return -1;
- Py_XSETREF(self->unconsumed_tail, new_data);
+ Py_SETREF(self->unconsumed_tail, new_data);
}
return 0;
}