Index: Objects/object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.164 diff -u -r2.164 object.c --- Objects/object.c 2 Mar 2002 08:43:19 -0000 2.164 +++ Objects/object.c 9 Mar 2002 11:52:55 -0000 @@ -480,6 +480,10 @@ c = (*f)(v, w); if (c < 0 && PyErr_Occurred()) return -1; + if (c < -1 || c > 1) + PyErr_Warn(PyExc_RuntimeWarning, + "tp_compare result is neither -1, 0, nor 1"); + return c < 0 ? -1 : c > 0 ? 1 : 0; } @@ -502,6 +506,9 @@ Py_DECREF(w); if (c < 0 && PyErr_Occurred()) return -2; + if (c < -1 || c > 1) + PyErr_Warn(PyExc_RuntimeWarning, + "tp_compare result is neither -1, 0, nor 1"); return c < 0 ? -1 : c > 0 ? 1 : 0; } @@ -512,6 +519,9 @@ Py_DECREF(w); if (c < 0 && PyErr_Occurred()) return -2; + if (c < -1 || c > 1) + PyErr_Warn(PyExc_RuntimeWarning, + "tp_compare result is neither -1, 0, nor 1"); return c < 0 ? 1 : c > 0 ? -1 : 0; /* negated! */ } @@ -605,6 +615,9 @@ if (v->ob_type == w->ob_type && (f = v->ob_type->tp_compare) != NULL) { c = (*f)(v, w); + if ((c < -1 || c > 1) && !PyInstance_Check(v)) + PyErr_Warn(PyExc_RuntimeWarning, + "tp_compare result is neither -1, 0, nor 1"); if (c != 2 || !PyInstance_Check(v)) return c; } @@ -904,6 +917,9 @@ res = NULL; goto Done; } + if (c < -1 || c > 1) + PyErr_Warn(PyExc_RuntimeWarning, + "tp_compare result is neither -1, 0, nor 1"); res = convert_3way_to_object(op, c); goto Done; }