Aleš Erjavec avatar Aleš Erjavec committed e3921bb

Changed the Value_richcmp function's handling of unknown values.

It is now more consistent with TValue.compare method.

Will now raise a TypeError when testing equality between unknown values
of a different type.

(fixes #1332)

Comments (0)

Files changed (1)

source/orange/cls_value.cpp

       if (val1.varType != val2.varType)
         PYERROR(PyExc_TypeError, "Value.compare: can't compare values of different types", PYNULL)
 
-      if (val1.isSpecial() || val2.isSpecial())
-        if ((op==Py_EQ) || (op==Py_NE)) {
-          PyObject *res = (val1.valueType==val2.valueType) == (op==Py_EQ) ? Py_True : Py_False;
-          Py_INCREF(res);
-          return res;
-        }
-        else {
-          Py_INCREF(Py_NotImplemented);
-          return Py_NotImplemented;
-        }
-
       // Nominal values of different attributes are treated separately
       PVariable &var1 = i->variable;
       PVariable &var2 = PyValue_AS_Variable(j);
       if (!convertFromPython(j, val2, i->variable))
         return PYNULL;
 
-      if (val1.isSpecial() || val2.isSpecial())
-        if ((op==Py_EQ) || (op==Py_NE)) {
-          PyObject *res = (val1.valueType==val2.valueType) == (op==Py_EQ) ? Py_True : Py_False;
-          Py_INCREF(res);
-          return res;
-        }
-        else {
-          Py_INCREF(Py_NotImplemented);
-          return Py_NotImplemented;
-        }
-
       return richcmp_from_sign(val1.compare(val2), op);
     }
       
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.