summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-01-26 07:57:07 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-01-26 07:57:07 (GMT)
commitf4b7a02e932671c6e54e6b48340173cc859ab4c0 (patch)
treeeaa9107bb2885a9ed40f9c697a31049826324dde /Objects
parent155ceaa454ad9a623cade5ed326e6e1e70ce109d (diff)
downloadcpython-f4b7a02e932671c6e54e6b48340173cc859ab4c0.zip
cpython-f4b7a02e932671c6e54e6b48340173cc859ab4c0.tar.gz
cpython-f4b7a02e932671c6e54e6b48340173cc859ab4c0.tar.bz2
Issue #21408: The default __ne__() now returns NotImplemented if __eq__()
returned NotImplemented. Removed incorrect implementations of __ne__().
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 3b1d189..1d98fc2 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3348,9 +3348,14 @@ object_richcompare(PyObject *self, PyObject *other, int op)
break;
case Py_NE:
- /* By default, != returns the opposite of ==,
+ /* By default, __ne__() delegates to __eq__() and inverts the result,
unless the latter returns NotImplemented. */
- res = PyObject_RichCompare(self, other, Py_EQ);
+ if (self->ob_type->tp_richcompare == NULL) {
+ res = Py_NotImplemented;
+ Py_INCREF(res);
+ break;
+ }
+ res = (*self->ob_type->tp_richcompare)(self, other, Py_EQ);
if (res != NULL && res != Py_NotImplemented) {
int ok = PyObject_IsTrue(res);
Py_DECREF(res);