mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
3d4ca74bc8
commit
4a1f593df5
4 changed files with 62 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue