R
Read Roberts
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 =
PyString_AsString(pyStringResult);
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");
PyErr_Clear();
}
PyArg_ParseTuple fails, and returns NULL. How come? By the
documentation, I would think that PyArg_ParseTuple would parse any
Python tuple object.
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 =
PyString_AsString(pyStringResult);
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");
PyErr_Clear();
}
PyArg_ParseTuple fails, and returns NULL. How come? By the
documentation, I would think that PyArg_ParseTuple would parse any
Python tuple object.