Changeset 11724:e3921bbbecaa in orange


Ignore:
Timestamp:
10/08/13 13:46:52 (6 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/cls_value.cpp

    r11703 r11724  
    482482        PYERROR(PyExc_TypeError, "Value.compare: can't compare values of different types", PYNULL) 
    483483 
    484       if (val1.isSpecial() || val2.isSpecial()) 
    485         if ((op==Py_EQ) || (op==Py_NE)) { 
    486           PyObject *res = (val1.valueType==val2.valueType) == (op==Py_EQ) ? Py_True : Py_False; 
    487           Py_INCREF(res); 
    488           return res; 
    489         } 
    490         else { 
    491           Py_INCREF(Py_NotImplemented); 
    492           return Py_NotImplemented; 
    493         } 
    494  
    495484      // Nominal values of different attributes are treated separately 
    496485      PVariable &var1 = i->variable; 
     
    568557      if (!convertFromPython(j, val2, i->variable)) 
    569558        return PYNULL; 
    570  
    571       if (val1.isSpecial() || val2.isSpecial()) 
    572         if ((op==Py_EQ) || (op==Py_NE)) { 
    573           PyObject *res = (val1.valueType==val2.valueType) == (op==Py_EQ) ? Py_True : Py_False; 
    574           Py_INCREF(res); 
    575           return res; 
    576         } 
    577         else { 
    578           Py_INCREF(Py_NotImplemented); 
    579           return Py_NotImplemented; 
    580         } 
    581559 
    582560      return richcmp_from_sign(val1.compare(val2), op); 
Note: See TracChangeset for help on using the changeset viewer.