Help on convert PyObject to string (c) Python 3.6
Jason Qian
jqian at tibco.com
Sun Feb 4 11:52:00 EST 2018
Hi,
This is the case of calling python from c and the python function will
return a string.
It seems python been called correctly, but got error when convert the
python string to c string.
-- c --
PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
-- python --
import string, random
def StringGen(argv):
out_string_size=int(argv);
output_data=''.join(random.choice(string.ascii_lowercase) for x in
range(out_string_size))
return output_data
I try:
PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
const char* sp = 0;
if (!PyArg_ParseTuple(pValue, "s", &sp)) {
}
and got
"SystemError: new style getargs format but argument is not a tuple"
Thanks for the help
More information about the Python-list
mailing list