Segfault when trying to call a Python function from C -
so, want call python callback function c.
at point, function sent c , packed tuple this
pyobject *userdata = py_buildvalue("oi",py_callback,some_number);
somewhere in area, py_incref(py_callback)
, too.
@ later time in program, want call function
pyobject *py_callback; int some_number; pyarg_parsetuple((pyobject*)userdata,"oi",&py_callback,&some_number); // returns true pyobject *py_result = pyobject_callfunctionobjargs(py_callback, /* ... */ null);
and last call throws segmentation fault. have idea, why such thing?
when getting weird behaviour python c api, worth double checking managing state of global interpreter lock (aka "the gil") correctly: http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock
Comments
Post a Comment