From dd84e5b97837df02e619529efdb74f2a9648f009 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 29 Sep 2008 18:17:53 +0000 Subject: [PATCH] print exception --- panda/src/pipeline/thread.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/panda/src/pipeline/thread.cxx b/panda/src/pipeline/thread.cxx index a0ef82f9ec..5c412ae237 100644 --- a/panda/src/pipeline/thread.cxx +++ b/panda/src/pipeline/thread.cxx @@ -228,6 +228,21 @@ call_python_func(PyObject *function, PyObject *args) { // In the main thread, just call the function. result = PyObject_Call(function, args, NULL); + if (result == (PyObject *)NULL) { + // Temporarily save and restore the exception state so we can print a + // callback on-the-spot. + PyObject *exc, *val, *tb; + PyErr_Fetch(&exc, &val, &tb); + + Py_XINCREF(exc); + Py_XINCREF(val); + Py_XINCREF(tb); + PyErr_Restore(exc, val, tb); + PyErr_Print(); + + PyErr_Restore(exc, val, tb); + } + } else { #ifdef SIMPLE_THREADS // We can't use the PyGILState interface, which assumes we are using