Quoting Aaron Optimizer Digulla <[EMAIL PROTECTED]>:
> I'm currently working on a patch for pygtk-0.6.5 which will call
> a user-callback in case of an error. That would allow to open a
> window with a trace instead of silently dying.
Ok, here is the patch. It will add a function
"pygtk_set_exception_handler" to gtk.py which allows to specify a
function or method (anything callable) which will be called when
an exception occurrs. Try this:
import os
os.environ['PYGTK_FATAL_EXCEPTIONS'] = '1'
def handler ():
import traceback
print 'GOTCHA'
traceback.print_exc ()
mainquit ()
pygtk_set_exception_handler (handler)
pygtk_set_exception_handler() will return the last installed
handler, so you can implement a stack if you want/need that.
The C code which calls the handler has a fallback mode. If
there are errors calling the handler (for example, an exception
in the handler), it will default to the old behaviour. There is
just one thing different: When the env variable PYGTK_FATAL_EXCEPTIONS
is set, then it will still print the exception and *then* it
will abort (the current code will just silently exit so you will
never know what happened).
Have fun,
--
==============================================
Sowatec AG, CH-8330 Pf�ffikon (ZH)
Witzbergstr. 7, http://www.sowatec.com
Tel: +41-(0)1-952 55 55
Fax: +41-(0)1-952 55 66
----------------------------------------------
Aaron "Optimizer" Digulla, [EMAIL PROTECTED]
==============================================
exception_handler.patch