Passing non-PyObjects as args to PyObject_CallObject
Hi all, My project uses GLib's GObject and recently I thought of adding support for executing python scripts by embedding the interpreter within the code. However there is this need to pass a GOB struct as one of the parameters to a function in the python script. How exactly do I pass non-PyObject types with the API?
I tried (to be clever) casting my GOB structure to PyObject and passing it in the args field of PyObject_CallObject. This of course turned out to be an EPIC FAIL with a nasty segfault. (I also tried Py_BuildValue with 'O&' signature)
It would be wonderful if some points me to some code which does this. From what I gather, do I need to create some sort of a Type Object which the Python API can understand? If it matters, I am using the 2.5 API.
Thanks and regards Sudharshan S Blog : http://www.sudharsh.wordpress.com IRC : Sup3rkiddo @ Freenode, Gimpnet
"Sudharshan S" <sudharsh@gmail.com> writes:
My project uses GLib's GObject and recently I thought of adding support for executing python scripts by embedding the interpreter within the code. However there is this need to pass a GOB struct as one of the parameters to a function in the python script. How exactly do I pass non-PyObject types with the API?
The gobject wrapper probably supports converting a GObject instance to a PyGobject visible from Python. Failing that, you can always create a PyCObject (an opaque object containing a pointer) and use it to pass the pointer to your struct.
participants (2)
-
Hrvoje Niksic
-
Sudharshan S