[pygtk] Catching Py errors after emitting C GSignals

Milosz Derezynski internalerror at gmail.com
Fri Jul 25 06:03:18 WST 2008

We've got a problem with handling Python errors after emitting C GSignals.
The problem is as follows:

We embed Python in our app. It's pretty normal embedding for the purpose of
Most of the plugins use (py-) gobject or gtk in some way (in Python), and
most also
connect to GSignals created in C-space of some of our app's objects.

Now, sometimes some plugin doesn't work right when it's being developed or
other unhandled error
situations occur. We'd like to catch these errors and display them trough
our GUI.

What i tried is this:
(the code is C++)

PyGILState_STATE state = (PyGILState_STATE)(pyg_gil_state_ensure ());
g_signal_emit (G_OBJECT(gobj()), signals[PSIGNAL_NEW_COVERART], 0);

What check_py_error() does (or did, in various variants testing it) was to
check for PyErr_Occured(), then, when this
didn't work, using pyg_gerror_exception_check() and then pyg_error_check().

None of these would indicate that there was an error even if one occured.

I assume that i just don't understand enough (or actually nothing at all) of
what exactly PyGTK does when
bridging the C signals to Python callbacks, but I thought it's all
synchronous so when an error
occured, I'd be able to fetch it after the signal emission is finished.

Would someone please be so kind and shed some light on this issue as we'd
really like to present
the errors through a GUI instead of just letting the app fail in the

Thanks very much in advance :)

-- Milosz

Please note that according to the German law on data retention,
information on every electronic information exchange with me is
retained for a period of six months.
[Bitte beachten Sie, dass dem Gesetz zur Vorratsdatenspeicherung zufolge
jeder elektronische Kontakt mit mir sechs Monate lang gespeichert wird.]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20080725/fab490a8/attachment.htm 

More information about the pygtk mailing list