summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2001-05-23 13:18:30 (GMT)
committerThomas Wouters <thomas@python.org>2001-05-23 13:18:30 (GMT)
commit6db14192e65f477a3804bedbe0b89c8c423fee90 (patch)
tree1f99c5e856e0513a4488202c528189c94062a61e
parent5bc57be5561cea97dcd4f23a8e666157af5d1207 (diff)
downloadcpython-6db14192e65f477a3804bedbe0b89c8c423fee90.zip
cpython-6db14192e65f477a3804bedbe0b89c8c423fee90.tar.gz
cpython-6db14192e65f477a3804bedbe0b89c8c423fee90.tar.bz2
Backport Tim's checkin 2.130:
SF bug #422108 - Error in rich comparisons. Fix a bad (albeit unlikely) return value in try_rich_to_3way_compare(). Also document do_cmp()'s return values.
-rw-r--r--Objects/object.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 2c033f8..dbf29e0 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -447,7 +447,7 @@ try_rich_to_3way_compare(PyObject *v, PyObject *w)
for (i = 0; i < 3; i++) {
switch (try_rich_compare_bool(v, w, tries[i].op)) {
case -1:
- return -1;
+ return -2;
case 1:
return tries[i].outcome;
}
@@ -585,6 +585,12 @@ default_3way_compare(PyObject *v, PyObject *w)
#define CHECK_TYPES(o) PyType_HasFeature((o)->ob_type, Py_TPFLAGS_CHECKTYPES)
+/* Do a 3-way comparison, by hook or by crook. Return:
+ -2 for an exception;
+ -1 if v < w;
+ 0 if v == w;
+ 1 if v > w;
+*/
static int
do_cmp(PyObject *v, PyObject *w)
{