https://github.com/python/cpython/commit/b4a6bbdd7de8bdc43ea62ed4bbb610bf1cd64278
commit: b4a6bbdd7de8bdc43ea62ed4bbb610bf1cd64278
branch: 3.11
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: serhiy-storchaka <storch...@gmail.com>
date: 2024-01-10T10:50:51Z
summary:

[3.11] gh-113877: Fix Tkinter method winfo_pathname() on 64-bit Windows 
(GH-113900) (GH-113902)

winfo_id() converts the result of "winfo id" command to integer, but
"winfo pathname" command requires an argument to be a hexadecimal number
on Win64.
(cherry picked from commit 1b7e0024a16c1820f61c04a8a100498568410afd)

Co-authored-by: Serhiy Storchaka <storch...@gmail.com>

files:
A Misc/NEWS.d/next/Library/2024-01-10-12-03-38.gh-issue-113877.RxKlrQ.rst
M Lib/tkinter/__init__.py
M Lib/tkinter/test/test_tkinter/test_misc.py

diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
index 05558e97733cd9..012737c0d7bae3 100644
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -1181,6 +1181,8 @@ def winfo_parent(self):
 
     def winfo_pathname(self, id, displayof=0):
         """Return the pathname of the widget given by ID."""
+        if isinstance(id, int):
+            id = hex(id)
         args = ('winfo', 'pathname') \
                + self._displayof(displayof) + (id,)
         return self.tk.call(args)
diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py 
b/Lib/tkinter/test/test_tkinter/test_misc.py
index aa11e65ea948ce..11f5b32e4b8995 100644
--- a/Lib/tkinter/test/test_tkinter/test_misc.py
+++ b/Lib/tkinter/test/test_tkinter/test_misc.py
@@ -227,6 +227,18 @@ def assertApprox(col1, col2):
         with self.assertRaises(tkinter.TclError):
             rgb((111, 78, 55))
 
+    def test_winfo_pathname(self):
+        t = tkinter.Toplevel(self.root)
+        w = tkinter.Button(t)
+        wid = w.winfo_id()
+        self.assertIsInstance(wid, int)
+        self.assertEqual(self.root.winfo_pathname(hex(wid)), str(w))
+        self.assertEqual(self.root.winfo_pathname(hex(wid), displayof=None), 
str(w))
+        self.assertEqual(self.root.winfo_pathname(hex(wid), displayof=t), 
str(w))
+        self.assertEqual(self.root.winfo_pathname(wid), str(w))
+        self.assertEqual(self.root.winfo_pathname(wid, displayof=None), str(w))
+        self.assertEqual(self.root.winfo_pathname(wid, displayof=t), str(w))
+
     def test_event_repr_defaults(self):
         e = tkinter.Event()
         e.serial = 12345
diff --git 
a/Misc/NEWS.d/next/Library/2024-01-10-12-03-38.gh-issue-113877.RxKlrQ.rst 
b/Misc/NEWS.d/next/Library/2024-01-10-12-03-38.gh-issue-113877.RxKlrQ.rst
new file mode 100644
index 00000000000000..173e185fe6c632
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-10-12-03-38.gh-issue-113877.RxKlrQ.rst
@@ -0,0 +1 @@
+Fix :mod:`tkinter` method ``winfo_pathname()`` on 64-bit Windows.

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to