Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6cf04f1

Browse files
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.
1 parent 7768ff1 commit 6cf04f1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Lib/tkinter/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,9 +1723,13 @@ def _substitute(self, *args):
17231723
def getint_event(s):
17241724
"""Tk changed behavior in 8.4.2, returning "??" rather more often."""
17251725
try:
1726-
return getint(s)
1726+
return getint(unpack(s))
17271727
except (ValueError, TclError):
17281728
return s
1729+
def unpack(s):
1730+
if isinstance(s, tuple) and len(s) == 1:
1731+
s, = s
1732+
return s
17291733

17301734
nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D = args
17311735
# Missing: (a, c, d, m, o, v, B, R)
@@ -1754,8 +1758,8 @@ def getint_event(s):
17541758
e.width = getint_event(w)
17551759
e.x = getint_event(x)
17561760
e.y = getint_event(y)
1757-
e.char = A
1758-
try: e.send_event = getboolean(E)
1761+
e.char = unpack(A)
1762+
try: e.send_event = getboolean(unpack(E))
17591763
except TclError: pass
17601764
e.keysym = K
17611765
e.keysym_num = getint_event(N)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix errors in calling Tkinter bindings on Windows.

0 commit comments

Comments
 (0)