Bug #6358. gc.DEBUG_OBJECTS removed from python3. Also handle exceptions due to collected weak references.

svn: r21299
This commit is contained in:
Gary Burton 2013-02-04 22:01:19 +00:00
parent bb3ac61359
commit 41fdca39dd

View File

@ -99,7 +99,10 @@ class Leak(tool.Tool, ManagedWindow):
self.list.append_column(column)
self.selection = self.list.get_selection()
gc.set_debug(gc.DEBUG_UNCOLLECTABLE|gc.DEBUG_OBJECTS|gc.DEBUG_SAVEALL)
flags = gc.DEBUG_UNCOLLECTABLE|gc.DEBUG_SAVEALL
if hasattr(gc, "DEBUG_OBJECTS"):
flags = flags | gc.DEBUG_OBJECTS
gc.set_debug(flags)
self.set_window(self.window, self.glade.get_object('title'),
self.title)
@ -130,7 +133,10 @@ class Leak(tool.Tool, ManagedWindow):
referrers = gc.get_referrers(self.modeldata[count])
text = ""
for referrer in referrers:
text += str(referrer) + '\n'
try:
text += str(referrer) + '\n'
except ReferenceError:
pass
InfoDialog(_('Referrers of %d') % count, text,
parent=self.window)
@ -141,7 +147,10 @@ class Leak(tool.Tool, ManagedWindow):
referents = gc.get_referents(self.modeldata[count])
text = ""
for referent in referents:
text += str(referent) + '\n'
try:
text += str(referent) + '\n'
except ReferenceError:
pass
InfoDialog(_('%d refers to') % count, text,
parent=self.window)
@ -157,6 +166,8 @@ class Leak(tool.Tool, ManagedWindow):
except DBError:
self.modeldata.append(each)
self.model.append((count, 'db.DB instance at %s' % id(each)))
except ReferenceError:
pass
count += 1
self.glade.get_object('label2').set_text(_('Uncollected Objects: %s') % str(len(gc.garbage)))