Help in unwrapping a PyObject* returned by an embedded Python function

Read Roberts rroberts at
Sat Jan 10 02:46:42 CET 2004

Environment: Mac OSX 10.2.4, vanilla Python 2.3.2 install

Why does PyArg_ParseTuple fail to parse a  return value which is a tuple?

When inside a C extension function, I  call a Python function :
    pyStringResult = PyEval_CallObject(pyEN_callback, arglist);

The Python function runs just fine, and returns a string value.
The following works fine, where name is (char**).

from Python callback function:		return myString
in calling C function: 			*name = 

However, the following does not work:
from Python callback function:		return (myString)
in calling C function:
	if (!PyArg_ParseTuple(pyStringResult, "s", name)) {
  		dbprintf(4, "c: failed to parse return value\n");
PyArg_ParseTuple fails, and returns NULL. How come? By the 
documentation, I would think that PyArg_ParseTuple would parse any 
Python tuple object.

Read K. Roberts			rroberts at
Adobe Systems San Jose TW12 	(408)-536-4402 on Weds
San Francisco 			(415) 642-5642 Mon, Tues, Thurs, Fri

More information about the Python-list mailing list