Add py3k warnings for object, type, cell and dict comparisons. This should resolve issue2342 and partly resolve issue2373.
diff --git a/Objects/cellobject.c b/Objects/cellobject.c
index b72d43b..37cde41 100644
--- a/Objects/cellobject.c
+++ b/Objects/cellobject.c
@@ -54,6 +54,12 @@
 static int
 cell_compare(PyCellObject *a, PyCellObject *b)
 {
+	/* Py3K warning for comparisons  */
+	if (Py_Py3kWarningFlag && PyErr_Warn(PyExc_DeprecationWarning,
+			"cell comparisons not supported in 3.x.") < 0) {
+		return NULL;
+	}
+
 	if (a->ob_ref == NULL) {
 		if (b->ob_ref == NULL)
 			return 0;
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 1246785..1ca2830 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1776,8 +1776,14 @@
 			return NULL;
 		res = (cmp == (op == Py_EQ)) ? Py_True : Py_False;
 	}
-	else
+	else {
+		/* Py3K warning if comparison isn't == or !=  */
+		if (Py_Py3kWarningFlag && PyErr_Warn(PyExc_DeprecationWarning,
+				"dict inequality comparisons not supported in 3.x.") < 0) {
+			return NULL;
+		}
 		res = Py_NotImplemented;
+	}
 	Py_INCREF(res);
 	return res;
  }
diff --git a/Objects/object.c b/Objects/object.c
index 698ba47..a10ac7c 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -863,8 +863,18 @@
 	int c;
 
 	c = try_3way_compare(v, w);
-	if (c >= 2)
+	if (c >= 2) {
+
+		/* Py3K warning if types are not equal and comparison isn't == or !=  */
+		if (Py_Py3kWarningFlag &&
+			v->ob_type != w->ob_type && op != Py_EQ && op != Py_NE &&
+			PyErr_Warn(PyExc_DeprecationWarning,
+				"comparing unequal types not supported in 3.x.") < 0) {
+			return NULL;
+		}
+
 		c = default_3way_compare(v, w);
+	}
 	if (c <= -2)
 		return NULL;
 	return convert_3way_to_object(op, c);
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 7db6dac..82ced39 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -593,6 +593,48 @@
 	return (vv < ww) ? -1 : (vv > ww) ? 1 : 0;
 }
 
+static PyObject*
+type_richcompare(PyObject *v, PyObject *w, int op)
+{
+	PyObject *result;
+	Py_uintptr_t vv, ww;
+	int c;
+
+	/* Make sure both arguments are types. */
+	if (!PyType_Check(v) || !PyType_Check(w)) {
+		result = Py_NotImplemented;
+		goto out;
+	}
+
+	/* Py3K warning if comparison isn't == or !=  */
+	if (Py_Py3kWarningFlag && op != Py_EQ && op != Py_NE &&
+		PyErr_Warn(PyExc_DeprecationWarning,
+			"type inequality comparisons not supported in 3.x.") < 0) {
+		return NULL;
+	}
+
+	/* Compare addresses */
+	vv = (Py_uintptr_t)v;
+	ww = (Py_uintptr_t)w;
+	switch (op) {
+	case Py_LT: c = vv <  ww; break;
+	case Py_LE: c = vv <= ww; break;
+	case Py_EQ: c = vv == ww; break;
+	case Py_NE: c = vv != ww; break;
+	case Py_GT: c = vv >  ww; break;
+	case Py_GE: c = vv >= ww; break;
+	default:
+		result = Py_NotImplemented;
+		goto out;
+	}
+	result = c ? Py_True : Py_False;
+
+  /* incref and return */
+  out:
+	Py_INCREF(result);
+	return result;
+}
+
 static PyObject *
 type_repr(PyTypeObject *type)
 {
@@ -2666,7 +2708,7 @@
 	type_doc,				/* tp_doc */
 	(traverseproc)type_traverse,		/* tp_traverse */
 	(inquiry)type_clear,			/* tp_clear */
-	0,					/* tp_richcompare */
+	type_richcompare,					/* tp_richcompare */
 	offsetof(PyTypeObject, tp_weaklist),	/* tp_weaklistoffset */
 	0,					/* tp_iter */
 	0,					/* tp_iternext */