[pygtk] trap gtk warnings

John Ehresman jpe at wingware.com
Sat Sep 16 04:33:46 WST 2006


skip at pobox.com wrote:
>     Michael> is there a way to trap gtk assertions in pygtk?  
> 
> None that I'm aware of.  I believe I've asked about this before as well.  It
> would be *really* nice if these got translated into Python exceptions by
> PyGTK.

They are routed through the python warnings module so you can log them 
to a file or stop in them in a debugger.  You can't really turn them 
into exceptions, though -- this could theoretically be added in some 
cases (maybe), but it's a fair amount of work.

The bigger problem is that a fair amount of C code doesn't handle the 
case where the assertion fails -- e.g. a call may be made to create a 
window & fails on an assert, but the next line assumes the window has 
been created and dereferences a pointer.  Trapping this is the same 
problem as trapping errors in buggy C code.  It's better to avoid 
failing on the assertion in the first place.

John


More information about the pygtk mailing list