0
$\begingroup$

I write Add-on using two callback functions, modal timer operator and binary module. When I develop this Add-on, then I write bug sometimes, but Python sometimes silently "die" and no error is printed to terminal. Do you have any advice?

Edit: problem was in Python binary module. Following code was wrong:

session_SessionObject *session = session_list[session_id];
if(session != NULL) {
    PyObject_CallMethod((PyObject*)session, "cb_receive_layer_destroy", "(IH)",
            node_id, layer_id);
}
return;

because it didn't check for return value of PyObject_CallMethod and it didn't try to "catch" errors from Python callback method. Following code is right:

session_SessionObject *session = session_list[session_id];
if(session != NULL) {
    PyObject *result = NULL;
    result = PyObject_CallMethod((PyObject*)session, "cb_receive_layer_destroy", "(IH)",
            node_id, layer_id);
    if(result == NULL || PyErr_Occurred() != NULL) {
        PyErr_Print();
    }
}
return;
$\endgroup$
5
  • 2
    $\begingroup$ Hey Jiri, Python should always print errors, though sometimes they don't show in as a message in the UI depending on the context, could you give an example script which shows this behavior? $\endgroup$
    – ideasman42
    Dec 3, 2014 at 8:15
  • $\begingroup$ Hi Campbell, I can't give you simple example of the script. The WIP code can be found at github: github.com/verse/verse-blender. It is very complex add-on and it uses binary module using pthreads. $\endgroup$
    – JiriHnidek
    Dec 3, 2014 at 13:35
  • $\begingroup$ Often time codes will create new variables when ones mentioned are not defined, what type of bug did you write? $\endgroup$
    – ruckus
    Dec 3, 2014 at 16:32
  • $\begingroup$ May be, there is problem with binary module: docs.python.org/3.4/extending/… $\endgroup$
    – JiriHnidek
    Dec 3, 2014 at 20:30
  • $\begingroup$ I found problem and solution, but I'm not sure if it is right place for such questions (may be, stackoverflow.com would be better). $\endgroup$
    – JiriHnidek
    Dec 4, 2014 at 20:59

0

You must log in to answer this question.

Browse other questions tagged .