From 41fdca39dd99bfc80fb6fc51643221ead2e12672 Mon Sep 17 00:00:00 2001 From: Gary Burton Date: Mon, 4 Feb 2013 22:01:19 +0000 Subject: [PATCH] Bug #6358. gc.DEBUG_OBJECTS removed from python3. Also handle exceptions due to collected weak references. svn: r21299 --- gramps/plugins/tool/leak.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gramps/plugins/tool/leak.py b/gramps/plugins/tool/leak.py index 061e9e297..f3ce11ea9 100644 --- a/gramps/plugins/tool/leak.py +++ b/gramps/plugins/tool/leak.py @@ -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)))