From f22fc553638dfc186d99df2e05eff807b98586df Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 13 Mar 2012 08:49:01 +0100 Subject: [PATCH] Return a NotImplemented exception when comparing Matrix or Vector with other types --- src/Base/MatrixPyImp.cpp | 5 +++-- src/Base/VectorPyImp.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Base/MatrixPyImp.cpp b/src/Base/MatrixPyImp.cpp index b4f37b89a..a5408bb18 100644 --- a/src/Base/MatrixPyImp.cpp +++ b/src/Base/MatrixPyImp.cpp @@ -159,8 +159,9 @@ PyObject* MatrixPy::richCompare(PyObject *v, PyObject *w, int op) } } else { - PyErr_SetString(PyExc_TypeError, "Cannot compare Matrix with other type"); - return 0; + // This always returns False + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; } } diff --git a/src/Base/VectorPyImp.cpp b/src/Base/VectorPyImp.cpp index 3476ac06a..da2bb5831 100644 --- a/src/Base/VectorPyImp.cpp +++ b/src/Base/VectorPyImp.cpp @@ -237,8 +237,9 @@ PyObject* VectorPy::richCompare(PyObject *v, PyObject *w, int op) } } else { - PyErr_SetString(PyExc_TypeError, "Cannot compare Matrix with other type"); - return 0; + // This always returns False + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; } }