Changeset 7782:b8685dc6e611 in orange


Ignore:
Timestamp:
03/28/11 20:43:49 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
c5dc3364d2c678ec32af2527753e13a12597b128
Message:

Fixed Variable pickling/unpickling (attribute 'name' is no longer in the attribute dictionary and must be pickled explicitly)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/lib_kernel.cpp

    r7715 r7782  
    514514{ 
    515515    PyTRY 
    516         return Py_BuildValue("O(ON)", getExportedFunction("__pickleLoaderVariable"), self->ob_type, packOrangeDictionary(self)); 
     516        PyObject *name = PyObject_GetAttrString(self, "name"); 
     517        PyObject *dict = packOrangeDictionary(self); 
     518        PyMapping_SetItemString(dict, "name", name); 
     519        Py_DECREF(name); 
     520    return Py_BuildValue("O(ON)", getExportedFunction("__pickleLoaderVariable"), self->ob_type, dict); //packOrangeDictionary(self)); 
    517521    PyCATCH 
    518522} 
     
    537541{ 
    538542    PyTRY 
    539         return Py_BuildValue("O(ON)", getExportedFunction("__pickleLoaderEnumVariable"), self->ob_type, packOrangeDictionary(self)); 
     543        PyObject *name = PyObject_GetAttrString(self, "name"); 
     544        PyObject *dict = packOrangeDictionary(self); 
     545        PyMapping_SetItemString(dict, "name", name); 
     546        Py_DECREF(name); 
     547        return Py_BuildValue("O(ON)", getExportedFunction("__pickleLoaderEnumVariable"), self->ob_type, dict); //packOrangeDictionary(self)); 
    540548    PyCATCH 
    541549} 
     
    560568    if (pyvalues) 
    561569      values = PyOrange_AsStringList((TPyOrange *)pyvalues).getUnwrappedPtr(); 
    562  
     570     
     571    if (!(values and name)) 
     572         PYERROR(PyExc_ValueError, "cannot construct the variable from the pickle", PYNULL) 
    563573    TVariable *var = TVariable::getExisting(name, TValue::INTVAR, values, NULL); 
    564574    PVariable pvar = var; 
Note: See TracChangeset for help on using the changeset viewer.