Ignore:
Timestamp:
01/11/12 13:59:50 (2 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
a589d6fdbf7fc737192e6044d7d74bc259579266
Message:

Fixed pickleLoaderDomain so it can load domains stored prior to the multiclass support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/lib_kernel.cpp

    r9415 r9529  
    15381538{ 
    15391539  PyTRY { 
    1540     if (!args || !PyTuple_Check(args) || (PyTuple_Size(args) != 6)) 
    1541       PYERROR(PyExc_TypeError, "invalid arguments for the domain unpickler", NULL); 
     1540    if (!args || !PyTuple_Check(args)) 
     1541        PYERROR(PyExc_TypeError, "invalid arguments for the domain unpickler", NULL) 
     1542 
     1543    int arg_size = PyTuple_Size(args); 
     1544 
     1545    if (!(arg_size == 6 || arg_size == 5)) 
     1546        PYERROR(PyExc_TypeError, "invalid arguments for the domain unpickler", NULL); 
    15421547 
    15431548    PyTypeObject *type = (PyTypeObject *)PyTuple_GET_ITEM(args, 0); 
    15441549    PyObject *attributes = PyTuple_GET_ITEM(args, 1); 
    15451550    PyObject *classVar = PyTuple_GET_ITEM(args, 2); 
    1546     PyObject *classVars = PyTuple_GET_ITEM(args, 3); 
    1547     PyObject *req_metas = PyTuple_GET_ITEM(args, 4); 
    1548     PyObject *opt_metas = PyTuple_GET_ITEM(args, 5); 
    1549  
    1550     if (!PyOrVarList_Check(attributes) || (classVars && !PyOrVarList_Check(attributes)) || !PyDict_Check(req_metas) || !PyDict_Check(opt_metas)) 
     1551 
     1552    PyObject *classVars = NULL; 
     1553    PyObject *req_metas = NULL; 
     1554    PyObject *opt_metas = NULL; 
     1555 
     1556    if (arg_size == 5) 
     1557    { 
     1558        // Old tuple format (pre multiclass support) 
     1559        req_metas = PyTuple_GET_ITEM(args, 3); 
     1560        opt_metas = PyTuple_GET_ITEM(args, 4); 
     1561 
     1562    } 
     1563    else 
     1564    { 
     1565        classVars = PyTuple_GET_ITEM(args, 3); 
     1566        req_metas = PyTuple_GET_ITEM(args, 4); 
     1567        opt_metas = PyTuple_GET_ITEM(args, 5); 
     1568    } 
     1569 
     1570    if (!PyOrVarList_Check(attributes) || (classVars && !PyOrVarList_Check(classVars)) || !PyDict_Check(req_metas) || !PyDict_Check(opt_metas)) 
    15511571      PYERROR(PyExc_TypeError, "invalid arguments for the domain unpickler", NULL); 
    15521572 
     
    15591579    else 
    15601580      PYERROR(PyExc_TypeError, "invalid arguments for the domain unpickler", NULL); 
    1561     domain->classVars = PyOrange_AsVarList(classVars); 
     1581 
     1582    if (classVars != NULL) 
     1583        domain->classVars = PyOrange_AsVarList(classVars); 
     1584    else 
     1585        domain->classVars = PVarList(new TVarList()); 
     1586 
    15621587 
    15631588    PyObject *pydomain = WrapNewOrange(domain, type); 
Note: See TracChangeset for help on using the changeset viewer.