diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-05-07 20:53:51 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-05-07 20:53:51 (GMT) |
commit | 6d60b2e762e028a5b40599cd283e2cd417c3fcd6 (patch) | |
tree | d3f5fa575fe68ad6b31aa135ba53d74d4f3ae6f5 /Objects | |
parent | b638aafef2e43c0edb8f53d6824e68a588799388 (diff) | |
download | cpython-6d60b2e762e028a5b40599cd283e2cd417c3fcd6.zip cpython-6d60b2e762e028a5b40599cd283e2cd417c3fcd6.tar.gz cpython-6d60b2e762e028a5b40599cd283e2cd417c3fcd6.tar.bz2 |
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.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/object.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c index f952405..c6d0591 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) { |