[capi-sig] Passing non-PyObjects as args to PyObject_CallObject

Sudharshan S sudharsh at gmail.com
Mon Oct 27 13:48:10 CET 2008

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
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

More information about the capi-sig mailing list