Need help with Tuples

Arinte shouldbe at message.com
Fri Dec 3 10:26:00 EST 1999


I have an python class that I send to my c program, when I try to get values
of the classes member variables the GetAttr is successful, but the
Py_ParseTuple always fail.   Has anyone ever experienced this problem?  I on
on windows python 1.5.2.  Here is the problematic c code...

  tobj = PyObject_GetItem(pobj, Py_BuildValue("i",idx) );
  vobj = PyObject_CallMethod(tobj,"getValue",NULL);
  Py_INCREF(vobj);
  val =PyObject_HasAttrString (tobj, "argvalue") ;  // returns 1
  val =PyObject_HasAttrString (tobj, "argname");  // returns 1
  if(vobj==NULL){   // not null
   appcallback()->messageBox("Error 0");
  }
  dummy = PyObject_Type(vobj);  // not null so I guess it is successful
  Py_INCREF(dummy);   // did I need to do this.  I do decref later
  char *tchar = "argvalue";
  nobj = PyObject_GetAttr(tobj,Py_BuildValue("s",tchar));  // nobj is not
null seems good
  if(!PyArg_ParseTuple(nobj, "i", &val)){  // fails every stinking time.
   appcallback()->messageBox("not again");
  }

Here is the class I pass to it
class PossArg:
 def __init__(self,argname, argvalue):
  self.argname = argname
  self.argvalue = argvalue
 def getValue(self):
  return self.argvalue
 def getName(self):
  return self.argname

TIA






More information about the Python-list mailing list