[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help on convert PyObject to string (c) Python 3.6


   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):
    output_data=''.join(random.choice(string.ascii_lowercase) for x in
    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