https://github.com/python/cpython/commit/24cddab4a20cc9fc218c80074457e8390060ed4c
commit: 24cddab4a20cc9fc218c80074457e8390060ed4c
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2025-01-02T16:14:18Z
summary:

[3.13] gh-128014:  Fix passing default='' to the tkinter method wm_iconbitmap() 
(GH-128015) (GH-128418)

(cherry picked from commit 58e9f95c4aa970db32a94b9152b51ede22f823bd)

Co-authored-by: Zhikang Yan <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>

files:
A Misc/NEWS.d/next/Library/2024-12-18-00-07-50.gh-issue-128014.F3aUbz.rst
M Lib/test/test_tkinter/test_misc.py
M Lib/tkinter/__init__.py

diff --git a/Lib/test/test_tkinter/test_misc.py 
b/Lib/test/test_tkinter/test_misc.py
index b0b9ed60040443..c7c1120ac48d18 100644
--- a/Lib/test/test_tkinter/test_misc.py
+++ b/Lib/test/test_tkinter/test_misc.py
@@ -4,7 +4,8 @@
 from tkinter import TclError
 import enum
 from test import support
-from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest, 
requires_tk
+from test.test_tkinter.support import (AbstractTkTest, AbstractDefaultRootTest,
+                                       requires_tk, get_tk_patchlevel)
 
 support.requires('gui')
 
@@ -540,6 +541,31 @@ def test_wm_attribute(self):
         self.assertEqual(w.wm_attributes('alpha'),
                          1.0 if self.wantobjects else '1.0')
 
+    def test_wm_iconbitmap(self):
+        t = tkinter.Toplevel(self.root)
+        self.assertEqual(t.wm_iconbitmap(), '')
+        t.wm_iconbitmap('hourglass')
+        bug = False
+        if t._windowingsystem == 'aqua':
+            # Tk bug 13ac26b35dc55f7c37f70b39d59d7ef3e63017c8.
+            patchlevel = get_tk_patchlevel(t)
+            if patchlevel < (8, 6, 17) or (9, 0) <= patchlevel < (9, 0, 2):
+                bug = True
+        if not bug:
+            self.assertEqual(t.wm_iconbitmap(), 'hourglass')
+        self.assertEqual(self.root.wm_iconbitmap(), '')
+        t.wm_iconbitmap('')
+        self.assertEqual(t.wm_iconbitmap(), '')
+
+        if t._windowingsystem == 'win32':
+            t.wm_iconbitmap(default='hourglass')
+            self.assertEqual(t.wm_iconbitmap(), 'hourglass')
+            self.assertEqual(self.root.wm_iconbitmap(), '')
+            t.wm_iconbitmap(default='')
+            self.assertEqual(t.wm_iconbitmap(), '')
+
+        t.destroy()
+
 
 class EventTest(AbstractTkTest, unittest.TestCase):
 
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
index 5352276e874bf5..51d97634d38a12 100644
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -2263,7 +2263,7 @@ def wm_iconbitmap(self, bitmap=None, default=None):
         explicitly.  DEFAULT can be the relative path to a .ico file
         (example: root.iconbitmap(default='myicon.ico') ).  See Tk
         documentation for more information."""
-        if default:
+        if default is not None:
             return self.tk.call('wm', 'iconbitmap', self._w, '-default', 
default)
         else:
             return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
diff --git 
a/Misc/NEWS.d/next/Library/2024-12-18-00-07-50.gh-issue-128014.F3aUbz.rst 
b/Misc/NEWS.d/next/Library/2024-12-18-00-07-50.gh-issue-128014.F3aUbz.rst
new file mode 100644
index 00000000000000..ef339a291f0ddd
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-12-18-00-07-50.gh-issue-128014.F3aUbz.rst
@@ -0,0 +1,2 @@
+Fix resetting the default window icon by passing ``default=''`` to the
+:mod:`tkinter` method :meth:`!wm_iconbitmap`.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to