summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorZhikang Yan <2951256653@qq.com>2025-01-02 15:51:57 (GMT)
committerGitHub <noreply@github.com>2025-01-02 15:51:57 (GMT)
commit58e9f95c4aa970db32a94b9152b51ede22f823bd (patch)
tree3f4c46324a829b28d820b042389c04ca1aa8b342 /Lib
parentc9d2bc6d7f6d74e0539afb0f7066997ae736dfc8 (diff)
downloadcpython-58e9f95c4aa970db32a94b9152b51ede22f823bd.zip
cpython-58e9f95c4aa970db32a94b9152b51ede22f823bd.tar.gz
cpython-58e9f95c4aa970db32a94b9152b51ede22f823bd.tar.bz2
gh-128014: Fix passing default='' to the tkinter method wm_iconbitmap() (GH-128015)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_tkinter/test_misc.py28
-rw-r--r--Lib/tkinter/__init__.py2
2 files changed, 28 insertions, 2 deletions
diff --git a/Lib/test/test_tkinter/test_misc.py b/Lib/test/test_tkinter/test_misc.py
index 475edcb..3362169 100644
--- a/Lib/test/test_tkinter/test_misc.py
+++ b/Lib/test/test_tkinter/test_misc.py
@@ -4,7 +4,8 @@ import tkinter
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')
@@ -554,6 +555,31 @@ class WmTest(AbstractTkTest, unittest.TestCase):
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 bfec04b..d494c0c 100644
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -2265,7 +2265,7 @@ class Wm:
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)