]> granicus.if.org Git - python/commitdiff
Update to MvL's patch #424475 to avoid returning 2 when tp_compare
authorGuido van Rossum <guido@python.org>
Thu, 16 Aug 2001 08:02:45 +0000 (08:02 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 16 Aug 2001 08:02:45 +0000 (08:02 +0000)
returns that.  (This fix is also by MvL; checkin it in because I want
to make more changes here.  I'm still not 100% satisfied -- see
comments attached to the patch.)

Objects/object.c

index 0d9b3fe5db0f7494f99630b18496a8e288b047df..e6021591199aa088192a8380f666afdf1b6128e2 100644 (file)
@@ -580,8 +580,11 @@ do_cmp(PyObject *v, PyObject *w)
        cmpfunc f;
 
        if (v->ob_type == w->ob_type
-           && (f = v->ob_type->tp_compare) != NULL)
-               return (*f)(v, w);
+           && (f = v->ob_type->tp_compare) != NULL) {
+               c = (*f)(v, w);
+               if (c != 2 || !PyInstance_Check(v))
+                       return c;
+       }
        c = try_rich_to_3way_compare(v, w);
        if (c < 2)
                return c;