[Python-checkins] cpython (3.5): Issue #27044: stop test_idle from leaking by deleting callbacks.

terry.reedy python-checkins at python.org
Mon May 16 22:28:20 EDT 2016


https://hg.python.org/cpython/rev/6a33d8d5d208
changeset:   101392:6a33d8d5d208
branch:      3.5
parent:      101389:c2b5334ac969
user:        Terry Jan Reedy <tjreedy at udel.edu>
date:        Mon May 16 22:27:28 2016 -0400
summary:
  Issue #27044: stop test_idle from leaking by deleting callbacks.

files:
  Lib/idlelib/configDialog.py                |  11 ++++++++++
  Lib/idlelib/idle_test/test_configdialog.py |   1 +
  2 files changed, 12 insertions(+), 0 deletions(-)


diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -483,6 +483,17 @@
         self.autoSave.trace_variable('w', self.VarChanged_autoSave)
         self.encoding.trace_variable('w', self.VarChanged_encoding)
 
+    def remove_var_callbacks(self):
+        "Remove callbacks to prevent memory leaks."
+        for var in (
+                self.fontSize, self.fontName, self.fontBold,
+                self.spaceNum, self.colour, self.builtinTheme,
+                self.customTheme, self.themeIsBuiltin, self.highlightTarget,
+                self.keyBinding, self.builtinKeys, self.customKeys,
+                self.keysAreBuiltin, self.winWidth, self.winHeight,
+                self.startupEdit, self.autoSave, self.encoding,):
+            var.trace_vdelete('w', var.trace_vinfo()[0][1])
+
     def VarChanged_font(self, *params):
         '''When one font attribute changes, save them all, as they are
         not independent from each other. In particular, when we are
diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py
--- a/Lib/idlelib/idle_test/test_configdialog.py
+++ b/Lib/idlelib/idle_test/test_configdialog.py
@@ -25,6 +25,7 @@
 
     def test_dialog(self):
         d=ConfigDialog(self.root, 'Test', _utest=True)
+        d.remove_var_callbacks()
         d.destroy()
 
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list