I am importing a shared object library written in C and calling to some wrapper functions I made that work using the Python.h library.
I have a function with the following prototype:
PyObject *Cal_readFile( PyObject *self, PyObject *args );
I parse out the following tuples:
PyArg_ParseTuple(args, "sO", &filename, &result)
From python the call looks like this:
result = []
status = Cal.readFile(filename, result)
print(result)
It is called fine, and the function definitely runs. My goal is to modify that result
variable within the C function that is called. And that is exactly what I do. I modify the result variable within the C function and am using result = Py_BuildValue("[lO]", (long)comp, compList);
to put new data into it.
However when I then print
result in Python I still have the same empty list I started with.
Is there some additional step I need to do to modify this python variable from the C function? I cannot use it in the return
as you already see that I am collecting a return status from there (this return works).
Edit: Some code from readCal that may be useful:
PyObject *result = NULL;
PyArg_ParseTuple(args, "sO", &filename, &result);
//Some creating of data is done, and then I am trying to set the list to that data:
result = Py_BuildValue("[lO]", (long)comp, compList);