Issue #4296: Fix PyObject_RichCompareBool so that "x in [x]" evaluates to

True, even when x doesn't compare equal to itself.  This was a regression
from 2.6.

Reviewed by R. Hettinger and C. Heimes.
This commit is contained in:
Mark Dickinson 2008-11-12 23:23:36 +00:00
parent 3d4ca74bc8
commit 4a1f593df5
4 changed files with 62 additions and 2 deletions

View file

@ -687,6 +687,15 @@ PyObject_RichCompareBool(PyObject *v, PyObject *w, int op)
PyObject *res;
int ok;
/* Quick result when objects are the same.
Guarantees that identity implies equality. */
if (v == w) {
if (op == Py_EQ)
return 1;
else if (op == Py_NE)
return 0;
}
res = PyObject_RichCompare(v, w, op);
if (res == NULL)
return -1;