diff --git a/Lib/idlelib/multicall.py b/Lib/idlelib/multicall.py index 41f81813113062..e1bbeb3e5c2cd5 100644 --- a/Lib/idlelib/multicall.py +++ b/Lib/idlelib/multicall.py @@ -334,6 +334,13 @@ def __init__(self, *args, **kwargs): def bind(self, sequence=None, func=None, add=None): #print("bind(%s, %s, %s)" % (sequence, func, add), # file=sys.__stderr__) + def wrapper(event): + if event.type == tkinter.EventType.Key: + # Check for any mismatch between event.char and event.keysym + if (len(event.char) and event.char.isprintable() + and event.char.lower() != event.keysym.lower()): + return None + return func(event) if type(sequence) is str and len(sequence) > 2 and \ sequence[:2] == "<<" and sequence[-2:] == ">>": if sequence in self.__eventinfo: @@ -341,13 +348,13 @@ def bind(self, sequence=None, func=None, add=None): if ei[0] is not None: for triplet in ei[1]: self.__binders[triplet[1]].unbind(triplet, ei[0]) - ei[0] = func + ei[0] = wrapper if ei[0] is not None: for triplet in ei[1]: - self.__binders[triplet[1]].bind(triplet, func) + self.__binders[triplet[1]].bind(triplet, wrapper) else: - self.__eventinfo[sequence] = [func, []] - return widget.bind(self, sequence, func, add) + self.__eventinfo[sequence] = [wrapper, []] + return widget.bind(self, sequence, wrapper, add) def unbind(self, sequence, funcid=None): if type(sequence) is str and len(sequence) > 2 and \ diff --git a/Misc/NEWS.d/next/IDLE/2024-10-12-08-08-37.gh-issue-125349.u0nToN.rst b/Misc/NEWS.d/next/IDLE/2024-10-12-08-08-37.gh-issue-125349.u0nToN.rst new file mode 100644 index 00000000000000..c730061c9f4bb5 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2024-10-12-08-08-37.gh-issue-125349.u0nToN.rst @@ -0,0 +1 @@ +Fixed unexpected behavior caused by the input method.