Issue #20437: Fixed 21 potential bugs when deleting objects references.
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 808e595..b312130 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -952,8 +952,7 @@
 PyFrame_Fini(void)
 {
     (void)PyFrame_ClearFreeList();
-    Py_XDECREF(builtin_object);
-    builtin_object = NULL;
+    Py_CLEAR(builtin_object);
 }
 
 /* Print summary info about the state of the optimized allocator */
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index ec3f91b..123df8c 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -866,8 +866,7 @@
     _Py_ForgetReference((PyObject *) v);
     /* DECREF items deleted by shrinkage */
     for (i = newsize; i < oldsize; i++) {
-        Py_XDECREF(v->ob_item[i]);
-        v->ob_item[i] = NULL;
+        Py_CLEAR(v->ob_item[i]);
     }
     sv = PyObject_GC_Resize(PyTupleObject, v, newsize);
     if (sv == NULL) {
@@ -913,8 +912,7 @@
 #if PyTuple_MAXSAVESIZE > 0
     /* empty tuples are used all over the place and applications may
      * rely on the fact that an empty tuple is a singleton. */
-    Py_XDECREF(free_list[0]);
-    free_list[0] = NULL;
+    Py_CLEAR(free_list[0]);
 
     (void)PyTuple_ClearFreeList();
 #endif
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index beafaa4..e1ff999 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1846,8 +1846,7 @@
 {
     _Py_Identifier *tmp, *s = static_strings;
     while (s) {
-        Py_DECREF(s->object);
-        s->object = NULL;
+        Py_CLEAR(s->object);
         tmp = s->next;
         s->next = NULL;
         s = tmp;
@@ -4082,8 +4081,7 @@
     return;
 
 onError:
-    Py_DECREF(*exceptionObject);
-    *exceptionObject = NULL;
+    Py_CLEAR(*exceptionObject);
 }
 
 /* error handling callback helper:
@@ -6224,8 +6222,7 @@
             goto onError;
         return;
       onError:
-        Py_DECREF(*exceptionObject);
-        *exceptionObject = NULL;
+        Py_CLEAR(*exceptionObject);
     }
 }
 
@@ -8225,8 +8222,7 @@
             goto onError;
         return;
       onError:
-        Py_DECREF(*exceptionObject);
-        *exceptionObject = NULL;
+        Py_CLEAR(*exceptionObject);
     }
 }