diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2016-05-17 02:27:28 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2016-05-17 02:27:28 (GMT) |
commit | 6b98ce23f686b5533ab4bcddfe2c9136565e4919 (patch) | |
tree | be85bdbaf247ec31d01b8e06bb0b1c6aaff101c1 /Lib/idlelib | |
parent | b461791b916a247b9e1e7eb0da1522ae58fb0ce3 (diff) | |
download | cpython-6b98ce23f686b5533ab4bcddfe2c9136565e4919.zip cpython-6b98ce23f686b5533ab4bcddfe2c9136565e4919.tar.gz cpython-6b98ce23f686b5533ab4bcddfe2c9136565e4919.tar.bz2 |
Issue #27044: stop test_idle from leaking by deleting callbacks.
Diffstat (limited to 'Lib/idlelib')
-rw-r--r-- | Lib/idlelib/configDialog.py | 11 | ||||
-rw-r--r-- | 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 index f00db39..b702253 100644 --- a/Lib/idlelib/configDialog.py +++ b/Lib/idlelib/configDialog.py @@ -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 diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py index 6883123..fab860b 100644 --- a/Lib/idlelib/idle_test/test_configdialog.py +++ b/Lib/idlelib/idle_test/test_configdialog.py @@ -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() |