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