Issue #20440: Cleaning up the code by using Py_SETREF.
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 00ebbf1..81a80b7 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -510,8 +510,6 @@
 static int
 gen_set_name(PyGenObject *op, PyObject *value)
 {
-    PyObject *tmp;
-
     /* Not legal to del gen.gi_name or to set it to anything
      * other than a string object. */
     if (value == NULL || !PyUnicode_Check(value)) {
@@ -519,10 +517,8 @@
                         "__name__ must be set to a string object");
         return -1;
     }
-    tmp = op->gi_name;
     Py_INCREF(value);
-    op->gi_name = value;
-    Py_DECREF(tmp);
+    Py_SETREF(op->gi_name, value);
     return 0;
 }
 
@@ -536,8 +532,6 @@
 static int
 gen_set_qualname(PyGenObject *op, PyObject *value)
 {
-    PyObject *tmp;
-
     /* Not legal to del gen.__qualname__ or to set it to anything
      * other than a string object. */
     if (value == NULL || !PyUnicode_Check(value)) {
@@ -545,10 +539,8 @@
                         "__qualname__ must be set to a string object");
         return -1;
     }
-    tmp = op->gi_qualname;
     Py_INCREF(value);
-    op->gi_qualname = value;
-    Py_DECREF(tmp);
+    Py_SETREF(op->gi_qualname, value);
     return 0;
 }