Re: C API : Creating a Py_Method object from a C function.

2005-07-12 Thread Martin v. Löwis
Hugh Macdonald wrote: > PyMethodDef *callbackFunctionDef = new PyMethodDef; > callbackFunctionDef->ml_name = "doLoadCallback"; > callbackFunctionDef->ml_meth = &myPython_doLoadCallback; > callbackFunctionDef->ml_flags = 1; I think this gives a memory leak. I was rather thinking of

Re: C API : Creating a Py_Method object from a C function.

2005-07-12 Thread Hugh Macdonald
Thanks Martin - that worked wonderfully For the record (and for anyone searching for this in future), here's the code that worked (with names changed to protect my job...) myPython is the C++/Python interface class containing static methods which pass on calls to the underlying python modul

Re: C API : Creating a Py_Method object from a C function.

2005-07-11 Thread Martin v. Löwis
Hugh Macdonald wrote: > The problem in this workflow is taking the C python function that I've > defined (using the standard "static PyObject *someFunction(PyObject > *self, PyObject *args)" method) and converting this into a Py_Object. > Any ideas? You should use PyCFunction_New(Ex), passing a st

C API : Creating a Py_Method object from a C function.

2005-07-11 Thread Hugh Macdonald
I've got a pure python module that parses a certain type of file. It has a load() function that allows a callback function to be passed for getting progress information. In straight python, this works fine. However, I'm now trying to use this from a C++ program. The current flow that I'm trying t