Python C Extension passing arguments by reference
-
29-10-2019 - |
Question
I am trying to write a python C wrapper for a function (libFunc) whose prototype is
libFunc(char**, int*, char*, int)
How do I use PyArg_ParseTuple for setting up the arguments for function call. Here is what I currently have
#include <Python.h>
PyObject* libFunc_py(PyObject* self, PyObject* args)
{
char* input;
char** output;
int inputlen;
int* outputlen;
PyArg_ParseTuple(args, "sisi" , output, outputlen, &input, &inputlen);
int ret = libFunc(output, outlen, input, inputlen);
return Py_BuildValue("i", ret);
}
I am able to do the same with ctypes using byref.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow