Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #92204
| From | dieter <dieter@handshake.de> |
|---|---|
| Subject | Re: Embedded Python and C Callback functions |
| Date | 2015-06-07 08:02 +0200 |
| References | <daad7377-7a61-4e9e-a442-4ba48f7212b2@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.229.1433656976.13271.python-list@python.org> (permalink) |
doc.mefisto@gmail.com writes: > Hi. I'm a newbie in python. But I want embed it in my C program. > > There is such method of my class: > @staticmethod > def install_instr_callback(callback): > # set hook for every change of PC > m68k.set_instr_hook_callback(callback) > > And in my C code there is such callback function: > static PyObject *my_instr_callback(PyObject *self); > > I want call install_instr_callback from C with specifying of my callback. I do: > PyObject_CallMethod(myClass, "install_instr_callback", "(O)", my_instr_callback); > But python writes me: [b]null argument to internal routine[/b]. If this output really comes from "PyObject_CallMethod", then some passed in argument is likely "null" - maybe "myclass"? The Python-C interface is complicated. It might be advicible to use e.g. "cython" to get the boilder plate code and some intricacies taken care of. I have done this with "dm.xmlsec.binding". You can find in its source also an example for the callback defined in Python and called from "C".
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Embedded Python and C Callback functions doc.mefisto@gmail.com - 2015-06-06 11:09 -0700
Re: Embedded Python and C Callback functions dieter <dieter@handshake.de> - 2015-06-07 08:02 +0200
Re: Embedded Python and C Callback functions doc.mefisto@gmail.com - 2015-06-07 01:37 -0700
Re: Embedded Python and C Callback functions doc.mefisto@gmail.com - 2015-06-07 01:56 -0700
Re: Embedded Python and C Callback functions Laura Creighton <lac@openend.se> - 2015-06-07 11:49 +0200
Re: Embedded Python and C Callback functions doc.mefisto@gmail.com - 2015-06-07 02:51 -0700
Re: Embedded Python and C Callback functions Stefan Behnel <stefan_ml@behnel.de> - 2015-06-07 22:32 +0200
Re: Embedded Python and C Callback functions doc.mefisto@gmail.com - 2015-06-07 02:15 -0700
Re: Embedded Python and C Callback functions dieter <dieter@handshake.de> - 2015-06-08 07:44 +0200
csiph-web