Changeset 8934:1ca0e5c464fa in orange


Ignore:
Timestamp:
09/09/11 12:36:44 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
b70ead4df7afd60e5581fc5c767cb56fbfbf7584
Message:

Moving get_value_from to the state dictionary in the Variable.reduce methods (in case it contains a recursive reference to the variable about to be pickled).
Fixes #887.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/lib_kernel.cpp

    r7783 r8934  
    518518        PyMapping_SetItemString(dict, "name", name); 
    519519        Py_DECREF(name); 
    520     return Py_BuildValue("O(ON)", getExportedFunction("__pickleLoaderVariable"), self->ob_type, dict); //packOrangeDictionary(self)); 
     520        PyObject *state = PyDict_New(); 
     521        PyObject *pygetvf = PyDict_GetItemString(dict, "get_value_from"); 
     522        if (pygetvf) { 
     523            // get_value_from can contain a reference to this variable itself 
     524            PyDict_SetItemString(state, "get_value_from", pygetvf); 
     525            PyDict_DelItemString(dict, "get_value_from"); 
     526        } 
     527        return Py_BuildValue("O(ON)N", getExportedFunction("__pickleLoaderVariable"), self->ob_type, dict, state); //packOrangeDictionary(self)); 
    521528    PyCATCH 
    522529} 
     530 
    523531 
    524532PyObject *__pickleLoaderVariable(PyObject *, PyObject *args) PYARGS(METH_VARARGS, "(type, dictionary)") 
     
    538546} 
    539547 
     548 
    540549PyObject *EnumVariable__reduce__(PyObject *self) 
    541550{ 
     
    545554        PyMapping_SetItemString(dict, "name", name); 
    546555        Py_DECREF(name); 
    547         return Py_BuildValue("O(ON)", getExportedFunction("__pickleLoaderEnumVariable"), self->ob_type, dict); //packOrangeDictionary(self)); 
     556        PyObject *state = PyDict_New(); 
     557        PyObject *pygetvf = PyDict_GetItemString(dict, "get_value_from"); 
     558        if (pygetvf) { 
     559            // get_value_from can contain a reference to this variable itself 
     560            PyDict_SetItemString(state, "get_value_from", pygetvf); 
     561            PyDict_DelItemString(dict, "get_value_from"); 
     562        } 
     563        return Py_BuildValue("O(ON)N", getExportedFunction("__pickleLoaderEnumVariable"), self->ob_type, dict, state); //packOrangeDictionary(self)); 
    548564    PyCATCH 
    549565} 
Note: See TracChangeset for help on using the changeset viewer.