Mercurial > cpython-lru_cache-weakref
diff Objects/object.c @ 49721:98628dc730da
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.
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Wed, 12 Nov 2008 23:23:36 +0000 |
| parents | 47192d0b731f |
| children | 1adfabcbe073 |
line wrap: on
line diff
--- a/Objects/object.c Wed Nov 12 21:39:01 2008 +0000 +++ b/Objects/object.c Wed Nov 12 23:23:36 2008 +0000 @@ -687,6 +687,15 @@ 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;
