mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
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.
This commit is contained in:
parent
b638aafef2
commit
6d60b2e762
1 changed files with 7 additions and 1 deletions
|
@ -447,7 +447,7 @@ try_rich_to_3way_compare(PyObject *v, PyObject *w)
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
switch (try_rich_compare_bool(v, w, tries[i].op)) {
|
switch (try_rich_compare_bool(v, w, tries[i].op)) {
|
||||||
case -1:
|
case -1:
|
||||||
return -1;
|
return -2;
|
||||||
case 1:
|
case 1:
|
||||||
return tries[i].outcome;
|
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)
|
#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
|
static int
|
||||||
do_cmp(PyObject *v, PyObject *w)
|
do_cmp(PyObject *v, PyObject *w)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue