Use Py_CLEAR instead of in-place DECREF/XDECREF or custom macros, for
tp_clear methods.
diff --git a/Objects/cellobject.c b/Objects/cellobject.c
index 9704403..e617e5e 100644
--- a/Objects/cellobject.c
+++ b/Objects/cellobject.c
@@ -81,8 +81,7 @@
 static int
 cell_clear(PyCellObject *op)
 {
-	Py_XDECREF(op->ob_ref);
-	op->ob_ref = NULL;
+	Py_CLEAR(op->ob_ref);
 	return 0;
 }
 
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 00ae2eb..b86319c 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -655,9 +655,7 @@
 static int
 cm_clear(classmethod *cm)
 {
-	Py_XDECREF(cm->cm_callable);
-	cm->cm_callable = NULL;
-
+	Py_CLEAR(cm->cm_callable);
 	return 0;
 }
 
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 1c74322..a0af2c9 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -559,8 +559,8 @@
 			char *addr = (char *)self + mp->offset;
 			PyObject *obj = *(PyObject **)addr;
 			if (obj != NULL) {
-				Py_DECREF(obj);
 				*(PyObject **)addr = NULL;
+				Py_DECREF(obj);
 			}
 		}
 	}
@@ -2236,13 +2236,6 @@
 	   for heaptypes. */
 	assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE);
 
-#define CLEAR(SLOT) \
-	if (SLOT) { \
-		tmp = (PyObject *)(SLOT); \
-		SLOT = NULL; \
-		Py_DECREF(tmp); \
-	}
-
 	/* The only field we need to clear is tp_mro, which is part of a
 	   hard cycle (its first element is the class itself) that won't
 	   be broken otherwise (it's a tuple and tuples don't have a
@@ -2268,9 +2261,7 @@
 	       A tuple of strings can't be part of a cycle.
 	*/
 
-	CLEAR(type->tp_mro);
-
-#undef CLEAR
+	Py_CLEAR(type->tp_mro);
 
 	return 0;
 }