]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix comparison of instances without _-cmp__
authorGuido van Rossum <guido@python.org>
Thu, 10 Nov 1994 22:31:02 +0000 (22:31 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 10 Nov 1994 22:31:02 +0000 (22:31 +0000)
Objects/classobject.c

index a3958010b1596643c890c088cb6c8423c42d60a1..7d8a8e9a78e75dd6ccd7924fcc11afc6881fda10 100644 (file)
@@ -524,14 +524,14 @@ instance_compare(inst, other)
        int outcome;
        result  = instancebinop(inst, other, "__cmp__", "__rcmp__");
        if (result == NULL) {
-               /* no __cmp__ or __rcmp__ methods, so use addresses */
+       error:
                err_clear();
-               return inst < other ? -1 : (inst > other ? 1 : 0);
+               return (inst < other) ? -1 : 1;
        }
        outcome = getintvalue(result);
        DECREF(result);
        if (outcome == -1 && err_occurred())
-               return -2;
+               goto error;
        if (outcome < 0)
                return -1;
        else if (outcome > 0)