[pygtk] GTK warning

Jeffrey Barish jeff_barish at earthlink.net
Mon Feb 23 02:09:21 WST 2009

I am getting a GTK warning that looks like this:

/myprog.py:118: Warning: g_object_unref: assertion `object->ref_count > 0' 

I am having a problem debugging this error because I don't see that I am 
unreferencing anything in line 118.  I learned from the GTK mailing list that 
it is possible in C to set --g-fatal-warnings when compiling to cause 
warnings like this one to become fatal errors so that there will be a 
backtrace to examine with gdb.  I then learned that it is possible to set the 
same flag in PyGTK by sticking it on the command line.  I was hoping to catch 
the exception and run pdb to examine the traceback using:

def do_debugger(type, value, tb):

if __name__ == "__main__":
    import sys
    sys.excepthook = do_debugger

However, the fatal error raised by GTK is SystemExit, which cannot be caught 
this way.  Does anyone have any tips on how to debug a GTK warning?
Jeffrey Barish

More information about the pygtk mailing list