]> granicus.if.org Git - python/commitdiff
Issue #27044: stop test_idle from leaking by deleting callbacks.
authorTerry Jan Reedy <tjreedy@udel.edu>
Tue, 17 May 2016 02:27:28 +0000 (22:27 -0400)
committerTerry Jan Reedy <tjreedy@udel.edu>
Tue, 17 May 2016 02:27:28 +0000 (22:27 -0400)
Lib/idlelib/configDialog.py
Lib/idlelib/idle_test/test_configdialog.py

index f00db39d8ffeb350f805d3b39ee3e8a47fada3c5..b7022537e61c76a1d39462549f7ac14e577b7008 100644 (file)
@@ -483,6 +483,17 @@ class ConfigDialog(Toplevel):
         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
index 68831236b76bd93a1047c6854ab2c1fb3c1dc037..fab860b43903c3186f340ee0b6883dd82ef76120 100644 (file)
@@ -25,6 +25,7 @@ class ConfigDialogTest(unittest.TestCase):
 
     def test_dialog(self):
         d=ConfigDialog(self.root, 'Test', _utest=True)
+        d.remove_var_callbacks()
         d.destroy()