]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Compare instance methods by comparing the object and the function.
authorGuido van Rossum <guido@python.org>
Thu, 3 Sep 1992 20:39:51 +0000 (20:39 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 3 Sep 1992 20:39:51 +0000 (20:39 +0000)
Objects/classobject.c

index d4a2f82401c274d8f83429d2c80691d0b86939ce..19f887cd71495b7ef663817bcebe49dfdcfe45fa 100644 (file)
@@ -828,6 +828,16 @@ instancemethod_dealloc(im)
        free((ANY *)im);
 }
 
+static int
+instancemethod_compare(a, b)
+       instancemethodobject *a, *b;
+{
+       int cmp = cmpobject(a->im_self, b->im_self);
+       if (cmp == 0)
+               cmp = cmpobject(a->im_func, b->im_func);
+       return cmp;
+}
+
 typeobject Instancemethodtype = {
        OB_HEAD_INIT(&Typetype)
        0,
@@ -838,7 +848,7 @@ typeobject Instancemethodtype = {
        0,                      /*tp_print*/
        instancemethod_getattr, /*tp_getattr*/
        0,                      /*tp_setattr*/
-       0,                      /*tp_compare*/
+       instancemethod_compare, /*tp_compare*/
        0,                      /*tp_repr*/
        0,                      /*tp_as_number*/
        0,                      /*tp_as_sequence*/