Use Py_CLEAR instead of in-place DECREF/XDECREF or custom macros, for
tp_clear methods.
diff --git a/Modules/_csv.c b/Modules/_csv.c
index 902ea9e..88c7248 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -828,12 +828,9 @@
 static int
 Reader_clear(ReaderObj *self)
 {
-        Py_XDECREF(self->dialect);
-        Py_XDECREF(self->input_iter);
-        Py_XDECREF(self->fields);
-        self->dialect = NULL;
-        self->input_iter = NULL;
-        self->fields = NULL;
+	Py_CLEAR(self->dialect);
+	Py_CLEAR(self->input_iter);
+	Py_CLEAR(self->fields);
 	return 0;
 }
 
@@ -1260,10 +1257,8 @@
 static int
 Writer_clear(WriterObj *self)
 {
-        Py_XDECREF(self->dialect);
-        Py_XDECREF(self->writeline);
-	self->dialect = NULL;
-	self->writeline = NULL;
+	Py_CLEAR(self->dialect);
+	Py_CLEAR(self->writeline);
 	return 0;
 }
 
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index 69e15e2..1d99fcb 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -2931,16 +2931,14 @@
 static int
 Pickler_clear(Picklerobject *self)
 {
-#define CLEAR(SLOT) Py_XDECREF(SLOT); SLOT = NULL;
-	CLEAR(self->write);
-	CLEAR(self->memo);
-	CLEAR(self->fast_memo);
-	CLEAR(self->arg);
-	CLEAR(self->file);
-	CLEAR(self->pers_func);
-	CLEAR(self->inst_pers_func);
-	CLEAR(self->dispatch_table);
-#undef CLEAR
+	Py_CLEAR(self->write);
+	Py_CLEAR(self->memo);
+	Py_CLEAR(self->fast_memo);
+	Py_CLEAR(self->arg);
+	Py_CLEAR(self->file);
+	Py_CLEAR(self->pers_func);
+	Py_CLEAR(self->inst_pers_func);
+	Py_CLEAR(self->dispatch_table);
 	return 0;
 }
 
@@ -5284,17 +5282,15 @@
 static int
 Unpickler_clear(Unpicklerobject *self)
 {
-#define CLEAR(SLOT) Py_XDECREF(SLOT); SLOT = NULL
-	CLEAR(self->readline);
-	CLEAR(self->read);
-	CLEAR(self->file);
-	CLEAR(self->memo);
-	CLEAR(self->stack);
-	CLEAR(self->pers_func);
-	CLEAR(self->arg);
-	CLEAR(self->last_string);
-	CLEAR(self->find_class);
-#undef CLEAR
+	Py_CLEAR(self->readline);
+	Py_CLEAR(self->read);
+	Py_CLEAR(self->file);
+	Py_CLEAR(self->memo);
+	Py_CLEAR(self->stack);
+	Py_CLEAR(self->pers_func);
+	Py_CLEAR(self->arg);
+	Py_CLEAR(self->last_string);
+	Py_CLEAR(self->find_class);
 	return 0;
 }
 
diff --git a/Modules/collectionsmodule.c b/Modules/collectionsmodule.c
index 5bccc7c..c7e2c85 100644
--- a/Modules/collectionsmodule.c
+++ b/Modules/collectionsmodule.c
@@ -1236,10 +1236,7 @@
 static int
 defdict_tp_clear(defdictobject *dd)
 {
-	if (dd->default_factory != NULL) {
-		Py_DECREF(dd->default_factory);
-		dd->default_factory = NULL;
-	}
+	Py_CLEAR(dd->default_factory);
 	return PyDict_Type.tp_clear((PyObject *)dd);
 }
 
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index b6e927d..fbef4e1 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1669,8 +1669,7 @@
 xmlparse_clear(xmlparseobject *op)
 {
     clear_handlers(op, 0);
-    Py_XDECREF(op->intern);
-    op->intern = 0;
+    Py_CLEAR(op->intern);
     return 0;
 }
 #endif