[Python-checkins] bpo-45160: Fix refleak in test_ttk_guionly introduced in GH-28291 (GH-29416)

ambv webhook-mailer at python.org
Fri Nov 5 04:52:04 EDT 2021


https://github.com/python/cpython/commit/54d1e3f72ed1ad8e860888c30ee7a285b931c0d1
commit: 54d1e3f72ed1ad8e860888c30ee7a285b931c0d1
branch: main
author: Łukasz Langa <lukasz at langa.pl>
committer: ambv <lukasz at langa.pl>
date: 2021-11-05T09:51:31+01:00
summary:

bpo-45160: Fix refleak in test_ttk_guionly introduced in GH-28291 (GH-29416)

files:
M Lib/tkinter/test/test_ttk/test_extensions.py

diff --git a/Lib/tkinter/test/test_ttk/test_extensions.py b/Lib/tkinter/test/test_ttk/test_extensions.py
index cddd1f2e84834..7fc1ebb95c970 100644
--- a/Lib/tkinter/test/test_ttk/test_extensions.py
+++ b/Lib/tkinter/test/test_ttk/test_extensions.py
@@ -310,9 +310,12 @@ def cb_test(*args):
             self.assertEqual(textvar.get(), items[1])
             success.append(True)
         optmenu = ttk.OptionMenu(self.root, textvar, "a", *items)
-        textvar.trace("w", cb_test)
+        optmenu.pack()
+        cb_name = textvar.trace("w", cb_test)
         optmenu['menu'].invoke(1)
         self.assertEqual(success, [True])
+        textvar.trace_vdelete("w", cb_name)
+        optmenu.destroy()
 
 
 class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):



More information about the Python-checkins mailing list