Extension problems (Python->C) (Att. prob.)

Andrew Kuchling akuchlin at mems-exchange.org
Fri Aug 18 12:10:51 EDT 2000


"Morten W. Petersen" <morten at src.no> writes:
>   if(!PyArg_ParseTuple(args, "s", &command))
>     return Py_BuildValue("s", "Oops");

This should be return NULL; PyArg_ParseTuple has set some exception
object as being raised, and your function simply needs to return NULL
to signal that there was some error.  If it doesn't return NULL, then
some other bit of the interpreter, perhaps in some completely
unrelated code, will later call to PyErr_Occurred and raise the
exception, which can be mystifying.

--amk



More information about the Python-list mailing list