summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/umath/loops.c.src11
1 files changed, 10 insertions, 1 deletions
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index ee7e7652d..c1e2dc1c5 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -2568,9 +2568,18 @@ OBJECT_@kind@(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUS
BINARY_LOOP {
PyObject *in1 = *(PyObject **)ip1;
PyObject *in2 = *(PyObject **)ip2;
- int ret = PyObject_RichCompareBool(
+ /*
+ * Do not use RichCompareBool because it includes an identity check.
+ * But this is wrong for elementwise behaviour, since i.e. it says
+ * that NaN can be equal to NaN, and an array is equal to itself.
+ */
+ PyObject *ret_obj = PyObject_RichCompare(
in1 ? in1 : Py_None,
in2 ? in2 : Py_None, Py_@OP@);
+ if (ret_obj == NULL) {
+ return;
+ }
+ int ret = PyObject_IsTrue(ret_obj);
if (ret == -1) {
return;
}