diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2008-11-12 23:23:36 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2008-11-12 23:23:36 (GMT) |
commit | 4a1f593df5d4733831a1c4f03ca40c701433c43d (patch) | |
tree | 0aea7b57d9c6fad40a32cca6be0993bd607ed9e2 /Objects | |
parent | 3d4ca74bc85c4224498e75704f82e4d42b6a04df (diff) | |
download | cpython-4a1f593df5d4733831a1c4f03ca40c701433c43d.zip cpython-4a1f593df5d4733831a1c4f03ca40c701433c43d.tar.gz cpython-4a1f593df5d4733831a1c4f03ca40c701433c43d.tar.bz2 |
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.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/object.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c index cdbceaf..2c43221 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -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; |