(arre, arigo)  SF bug #1350060

Give a consistent behavior for comparison and hashing of method objects
(both user- and built-in methods).  Now compares the 'self' recursively.
The hash was already asking for the hash of 'self'.
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 561ba4a5..606ef05 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -901,16 +901,28 @@
 static int
 wrapper_compare(wrapperobject *a, wrapperobject *b)
 {
-	if (a->descr == b->descr) {
-		if (a->self == b->self)
-			return 0;
-		else
-			return (a->self < b->self) ? -1 : 1;
-	}
+	if (a->descr == b->descr)
+		return PyObject_Compare(a->self, b->self);
 	else
 		return (a->descr < b->descr) ? -1 : 1;
 }
 
+static long
+wrapper_hash(wrapperobject *wp)
+{
+	int x, y;
+	x = _Py_HashPointer(wp->descr);
+	if (x == -1)
+		return -1;
+	y = PyObject_Hash(wp->self);
+	if (y == -1)
+		return -1;
+	x = x ^ y;
+	if (x == -1)
+		x = -2;
+	return x;
+}
+
 static PyObject *
 wrapper_repr(wrapperobject *wp)
 {
@@ -1008,7 +1020,7 @@
 	0,					/* tp_as_number */
 	0,					/* tp_as_sequence */
 	0,		       			/* tp_as_mapping */
-	0,					/* tp_hash */
+	(hashfunc)wrapper_hash,			/* tp_hash */
 	(ternaryfunc)wrapper_call,		/* tp_call */
 	0,					/* tp_str */
 	PyObject_GenericGetAttr,		/* tp_getattro */