1

How can I pass a c structure to python without using ctypes ?

I have a pointer to a stats_res_t structure that I'm trying to return to python.

I'm trying something along the lines of

PyObject* pyobject_get_system_stats(PyObject *self, PyObject *args)
{
    PyObject *temp;

    PyObject *resultlist;
    PyObject *res;
    stats_res_t *response;

    if(PyArg_ParseTuple(args,"O",&temp))
    {

        resultlist=PyDict_Values(temp);
        res=PyList_AsTuple(resultlist);

        // populate response

    }
    return Py_BuildValue("O",response);
}

but it causes segfault in python.

Is it possible to pass a populated structure to python using PyObject ?

P0W
  • 46,614
  • 9
  • 72
  • 119
nkshirsa
  • 11
  • 3
  • I'm no `PyObject` expert but probably giving `stats_res_t` definition might help too – P0W Mar 15 '15 at 00:58

0 Answers0