Issue #20440: Applied yet one patch for using Py_SETREF.
The patch is automatically generated, it replaces the code that uses Py_CLEAR.
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index dd518d7..9b2e5b2 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -1028,8 +1028,7 @@
         Py_CLEAR(res);
         goto end;
     }
-    Py_CLEAR(res);
-    res = _PyBytes_Join(_PyIO_empty_bytes, chunks);
+    Py_SETREF(res, _PyBytes_Join(_PyIO_empty_bytes, chunks));
 
 end:
     LEAVE_BUFFERED(self)
@@ -1264,9 +1263,8 @@
     if (_PyIOBase_check_readable(raw, Py_True) == NULL)
         return -1;
 
-    Py_CLEAR(self->raw);
     Py_INCREF(raw);
-    self->raw = raw;
+    Py_SETREF(self->raw, raw);
     self->buffer_size = buffer_size;
     self->readable = 1;
     self->writable = 0;
@@ -1687,9 +1685,8 @@
     if (_PyIOBase_check_writable(raw, Py_True) == NULL)
         return -1;
 
-    Py_CLEAR(self->raw);
     Py_INCREF(raw);
-    self->raw = raw;
+    Py_SETREF(self->raw, raw);
     self->readable = 0;
     self->writable = 1;
 
@@ -2344,9 +2341,8 @@
     if (_PyIOBase_check_writable(raw, Py_True) == NULL)
         return -1;
 
-    Py_CLEAR(self->raw);
     Py_INCREF(raw);
-    self->raw = raw;
+    Py_SETREF(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 9981d4c..bb4c5ef 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -966,8 +966,7 @@
                 "Oi", self->decoder, (int)self->readtranslate);
             if (incrementalDecoder == NULL)
                 goto error;
-            Py_CLEAR(self->decoder);
-            self->decoder = incrementalDecoder;
+            Py_SETREF(self->decoder, incrementalDecoder);
         }
     }
 
@@ -1347,8 +1346,7 @@
 static void
 textiowrapper_set_decoded_chars(textio *self, PyObject *chars)
 {
-    Py_CLEAR(self->decoded_chars);
-    self->decoded_chars = chars;
+    Py_SETREF(self->decoded_chars, chars);
     self->decoded_chars_used = 0;
 }
 
@@ -1477,8 +1475,7 @@
             goto fail;
         }
         Py_DECREF(dec_buffer);
-        Py_CLEAR(self->snapshot);
-        self->snapshot = Py_BuildValue("NN", dec_flags, next_input);
+        Py_SETREF(self->snapshot, Py_BuildValue("NN", dec_flags, next_input));
     }
     Py_DECREF(input_chunk);
 
@@ -1578,8 +1575,7 @@
         if (chunks != NULL) {
             if (result != NULL && PyList_Append(chunks, result) < 0)
                 goto fail;
-            Py_CLEAR(result);
-            result = PyUnicode_Join(_PyIO_empty_str, chunks);
+            Py_SETREF(result, PyUnicode_Join(_PyIO_empty_str, chunks));
             if (result == NULL)
                 goto fail;
             Py_CLEAR(chunks);
@@ -1836,8 +1832,7 @@
     if (chunks != NULL) {
         if (line != NULL && PyList_Append(chunks, line) < 0)
             goto error;
-        Py_CLEAR(line);
-        line = PyUnicode_Join(_PyIO_empty_str, chunks);
+        Py_SETREF(line, PyUnicode_Join(_PyIO_empty_str, chunks));
         if (line == NULL)
             goto error;
         Py_DECREF(chunks);
diff --git a/Modules/_struct.c b/Modules/_struct.c
index 02dd7d3..196a093 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -1377,15 +1377,13 @@
 
     if (PyString_Check(o_format)) {
         Py_INCREF(o_format);
-        Py_CLEAR(soself->s_format);
-        soself->s_format = o_format;
+        Py_SETREF(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_CLEAR(soself->s_format);
-        soself->s_format = str;
+        Py_SETREF(soself->s_format, str);
     }
     else {
         PyErr_Format(PyExc_TypeError,