PyArg_Parse weirds
Robin Becker
robin at jessikat.fsnet.co.uk
Tue Apr 24 11:49:43 EDT 2001
In article <m31yqieda7.fsf at atrus.jesus.cam.ac.uk>, Michael Hudson <mwh21 at cam.ac.uk>
writes
>Robin Becker <robin at jessikat.fsnet.co.uk> writes:
>
>> I just get 0 back from the PyArg_Parse so have to assume it didn't work
>> and as the value printed out suggests it hasn't put anything into r.
>
>If it's returned 0 and not set an exception, that's a bug. If it's
>set an exception, then that might give clues as to what's going on.
>
>There's always the C debugger for things like this, too.
>
>Cheers,
>M.
>
OK I figured out that PyArg_Parse seems to know about an existing error so I needed to
clear the existing error condition with PyErr_Clear ie
else if(PyObject_HasAttrString(value,"red")
&& PyObject_HasAttrString(value,"green")
&& PyObject_HasAttrString(value,"blue")){
double r, g, b;
PyObject *v;
PyErr_Clear(); /*needed this here else i==0 in pyArg_Parse call*/
v = PyObject_GetAttrString(value,"red");
i = PyArg_Parse(v,"d",&r);
--
Robin Becker
More information about the Python-list
mailing list