Skip to content

Commit

Permalink
pythongh-118760: Fix errors in calling Tkinter bindings on Windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
serhiy-storchaka committed May 8, 2024
1 parent 7768ff1 commit 6cf04f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Lib/tkinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix errors in calling Tkinter bindings on Windows.

0 comments on commit 6cf04f1

Please sign in to comment.