Changeset 4610:14d998ecfad6 in orange


Ignore:
Timestamp:
04/22/08 21:25:28 (6 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Convert:
818c7e6d063ee630d28f3c9606974a57752a24c1
Message:
  • changed the arguments for Example.getmetas (the caller can omit optional now)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/cls_example.cpp

    r4357 r4610  
    382382{ 
    383383  PyTRY 
     384    PyObject *pyoptional = NULL; 
    384385    PyTypeObject *keytype = &PyInt_Type; 
    385386    int optional = ILLEGAL_INT; 
    386     if (!PyArg_ParseTuple(args, "|iO:Example.getmetas", &optional, &keytype)) 
     387    if (!PyArg_ParseTuple(args, "|OO:Example.getmetas", &pyoptional, &keytype)) 
    387388      return NULL; 
    388389 
     390    if (!keytype && PyType_Check(pyoptional)) { 
     391      keytype = (PyTypeObject *)pyoptional; 
     392      pyoptional = NULL; 
     393    } 
     394     
     395    if (pyoptional) { 
     396      if (!PyInt_Check(pyoptional)) { 
     397        PyErr_Format(PyExc_TypeError, "invalid type for argument 'optional' (expected int, got '%s')", pyoptional->ob_type->tp_name); 
     398        return NULL; 
     399      } 
     400      optional = PyInt_AsLong(pyoptional); 
     401    } 
     402     
    389403    if ((keytype != &PyInt_Type) && (keytype != &PyString_Type) && (keytype != (PyTypeObject *)&PyOrVariable_Type)) 
    390404      PYERROR(PyExc_TypeError, "invalid key type (should be nothing, int, str, or orange.Variable)", NULL); 
Note: See TracChangeset for help on using the changeset viewer.