Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6d60b2e

Browse files
committed
SF bug #422108 - Error in rich comparisons.
2.1.1 bugfix candidate too. Fix a bad (albeit unlikely) return value in try_rich_to_3way_compare(). Also document do_cmp()'s return values.
1 parent b638aaf commit 6d60b2e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Objects/object.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ try_rich_to_3way_compare(PyObject *v, PyObject *w)
447447
for (i = 0; i < 3; i++) {
448448
switch (try_rich_compare_bool(v, w, tries[i].op)) {
449449
case -1:
450-
return -1;
450+
return -2;
451451
case 1:
452452
return tries[i].outcome;
453453
}
@@ -585,6 +585,12 @@ default_3way_compare(PyObject *v, PyObject *w)
585585

586586
#define CHECK_TYPES(o) PyType_HasFeature((o)->ob_type, Py_TPFLAGS_CHECKTYPES)
587587

588+
/* Do a 3-way comparison, by hook or by crook. Return:
589+
-2 for an exception;
590+
-1 if v < w;
591+
0 if v == w;
592+
1 if v > w;
593+
*/
588594
static int
589595
do_cmp(PyObject *v, PyObject *w)
590596
{

0 commit comments

Comments
 (0)