Issue #22570: Renamed Py_SETREF to Py_XSETREF.
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index 9cebaf4..5fd52d9 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -1608,7 +1608,7 @@
 
     /* 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 @@
 {
     /* 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 @@
 {
     /* 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 @@
     }
 
     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 @@
     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 9271413..e78ac95 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -277,7 +277,7 @@
         }
         else {
             Py_INCREF(src);
-            Py_SETREF(*target, src);
+            Py_XSETREF(*target, src);
         }
     }
     return 0;
@@ -769,7 +769,7 @@
 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 7d66d11..7f66d6a 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -424,7 +424,7 @@
         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 @@
         return -1;
     }
     Py_INCREF(proto);
-    Py_SETREF(stgdict->proto, proto);
+    Py_XSETREF(stgdict->proto, proto);
     return 0;
 }
 
@@ -992,7 +992,7 @@
         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 @@
         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 @@
         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 @@
         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 @@
     }
     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 @@
         return -1;
     }
     Py_XINCREF(ob);
-    Py_SETREF(self->errcheck, ob);
+    Py_XSETREF(self->errcheck, ob);
     return 0;
 }
 
@@ -3082,8 +3082,8 @@
         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 @@
         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 d61281e..dbc0f53 100644
--- a/Modules/_curses_panel.c
+++ b/Modules/_curses_panel.c
@@ -284,7 +284,7 @@
         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 a035c57..793d4c7 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -1574,7 +1574,7 @@
 
     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 @@
         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 @@
     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 @@
     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 @@
         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 2ad556d..b2cfd75 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -320,10 +320,10 @@
     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 9b2e5b2..600bf8a 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -1028,7 +1028,7 @@
         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 @@
         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 @@
         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 @@
         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 bb4c5ef..38bb0d8 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -966,7 +966,7 @@
                 "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 @@
 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 @@
             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 @@
         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 @@
     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 fede6b1..9c8f66c 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_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 c67d10c..9ced405 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -228,7 +228,7 @@
         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 @@
 
     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 @@
         }
     }
 
-    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 @@
         }
     }
 
-    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 3d5b8f3..b3ec8f2 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -172,7 +172,7 @@
         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 @@
 
     /* 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 @@
         (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 @@
     }
 
     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 @@
                 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 829fb6b..485020e 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -2054,7 +2054,7 @@
     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 23d4d5c..a44414b 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -1467,7 +1467,7 @@
         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 196a093..50fb138 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -1377,13 +1377,13 @@
 
     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 fe417c5..c33e03c 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_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 a00108e..cab7ca8 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -689,7 +689,7 @@
     }
     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 @@
     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 @@
         return -1;
     }
     Py_INCREF(v);
-    Py_SETREF(p->pers_func, v);
+    Py_XSETREF(p->pers_func, v);
     return 0;
 }
 
@@ -3240,7 +3240,7 @@
         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 @@
         return -1;
     }
     Py_INCREF(v);
-    Py_SETREF(p->memo, v);
+    Py_XSETREF(p->memo, v);
     return 0;
 }
 
@@ -5663,13 +5663,13 @@
 
     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 @@
             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 9ef8727..ddb2996 100644
--- a/Modules/cdmodule.c
+++ b/Modules/cdmodule.c
@@ -629,9 +629,9 @@
                   (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 68285b8..2493321 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -492,7 +492,7 @@
         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 c0e17f3..81674c8 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_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 8c7916e..f3282b2 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_SETREF(self->unused_data, new_data);
+            Py_XSETREF(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_SETREF(self->unconsumed_tail, new_data);
+        Py_XSETREF(self->unconsumed_tail, new_data);
     }
     return 0;
 }
@@ -731,9 +731,9 @@
     }
 
     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 @@
     }
 
     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;