From 6cf04f14a6141c6981221ed31c871a24e8b11edc Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 8 May 2024 21:07:20 +0300 Subject: [PATCH 1/2] gh-118760: Fix errors in calling Tkinter bindings on Windows For unknown reasons some arguments are passed as a 1-tuple containing a Tcl_Obj with type "string" and value "0" what wantobjects is 2. --- Lib/tkinter/__init__.py | 10 +++++++--- .../2024-05-08-21-13-56.gh-issue-118760.mdmH3T.rst | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2024-05-08-21-13-56.gh-issue-118760.mdmH3T.rst diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index daecf4eb2ea522..770801f6a5bda5 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -1723,9 +1723,13 @@ def _substitute(self, *args): def getint_event(s): """Tk changed behavior in 8.4.2, returning "??" rather more often.""" try: - return getint(s) + return getint(unpack(s)) except (ValueError, TclError): return s + def unpack(s): + if isinstance(s, tuple) and len(s) == 1: + s, = s + return s nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D = args # Missing: (a, c, d, m, o, v, B, R) @@ -1754,8 +1758,8 @@ def getint_event(s): e.width = getint_event(w) e.x = getint_event(x) e.y = getint_event(y) - e.char = A - try: e.send_event = getboolean(E) + e.char = unpack(A) + try: e.send_event = getboolean(unpack(E)) except TclError: pass e.keysym = K e.keysym_num = getint_event(N) diff --git a/Misc/NEWS.d/next/Library/2024-05-08-21-13-56.gh-issue-118760.mdmH3T.rst b/Misc/NEWS.d/next/Library/2024-05-08-21-13-56.gh-issue-118760.mdmH3T.rst new file mode 100644 index 00000000000000..89ef9334fbc65d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-05-08-21-13-56.gh-issue-118760.mdmH3T.rst @@ -0,0 +1 @@ +Fix errors in calling Tkinter bindings on Windows. From 91e7e7fef13c2c826fed5547d229d695c977f898 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 15 May 2024 18:59:21 +0300 Subject: [PATCH 2/2] Try other approach. --- Lib/tkinter/__init__.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index 770801f6a5bda5..f03da0ff5f98ec 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -1723,14 +1723,13 @@ def _substitute(self, *args): def getint_event(s): """Tk changed behavior in 8.4.2, returning "??" rather more often.""" try: - return getint(unpack(s)) + return getint(s) except (ValueError, TclError): return s - def unpack(s): - if isinstance(s, tuple) and len(s) == 1: - s, = s - return s + if any(isinstance(s, tuple) for s in args): + args = [s[0] if isinstance(s, tuple) and len(s) == 1 else s + for s in args] nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D = args # Missing: (a, c, d, m, o, v, B, R) e = Event() @@ -1758,8 +1757,8 @@ def unpack(s): e.width = getint_event(w) e.x = getint_event(x) e.y = getint_event(y) - e.char = unpack(A) - try: e.send_event = getboolean(unpack(E)) + e.char = A + try: e.send_event = getboolean(E) except TclError: pass e.keysym = K e.keysym_num = getint_event(N) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy