Embedded Python and C Callback functions

2015-06-06 Thread doc . mefisto
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].

How can I fix this problem?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Embedded Python and C Callback functions

2015-06-07 Thread doc . mefisto
No, myclass is not null. I think my style of passing arguments is wrong.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Embedded Python and C Callback functions

2015-06-07 Thread doc . mefisto
And I can't use Cython, because I have C++ module, and I have to use it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Embedded Python and C Callback functions

2015-06-07 Thread doc . mefisto
I'm trying to debug and find my error. It goes wrong when:
 PyObject *v;
v = va_arg(*p_va, PyObject *);
if (v != NULL) {
if (*(*p_format - 1) != 'N')
Py_INCREF(v);
}

it tries to PyINCREF to my passed callback.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Embedded Python and C Callback functions

2015-06-07 Thread doc . mefisto
> >And I can't use Cython, because I have C++ module, and I have to use it.
> >-- 
> >https://mail.python.org/mailman/listinfo/python-list
> 
> Are you using Boost?
> http://www.boost.org/doc/libs/1_58_0/libs/python/doc/
> 
> It handles lots of the setup for you.
> 
> Laura

No, I'm not using Boost. Pure Python.h
-- 
https://mail.python.org/mailman/listinfo/python-list