You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IDLE: Non-English IME input triggers single-letter shortcuts instead of typing characters (Windows) #162837
Description
When using IDLE with a non-English Input Method Editor (IME) (e.g., Microsoft Pinyin, Japanese IME) on Windows, typing code characters triggers single-letter IDLE shortcuts instead of inserting the characters into the editor. This makes it impossible to write code while the IME is active.
Steps to Reproduce
Open IDLE on Windows.
Switch the input method to a non-English IME (e.g., Microsoft Pinyin).
Ensure the IME is in a state where it would normally accept character input (e.g., typing pinyin).
Type print().
Observe that the characters p, r, and t do not appear in the editor. Instead, IDLE executes keyboard shortcuts bound to those single letters (e.g., p may trigger "Python Documentation", r triggers "Search Dialog").
Expected Behavior
The characters p, r, i, n, t should be inserted into the editor (or intercepted by the IME for composition), regardless of the active input method.
Actual Behavior
Single-letter shortcuts are triggered, and characters are lost.
Additional Context
This issue has existed for at least a decade.
The root cause appears to be that Tkinter's Text widget on Windows does not correctly handle the WM_IME_COMPOSITION message or properly identify the IME composition state. As a result, raw KeyPress events are captured by IDLE's key-binding mechanism before the IME can process them.
A fix likely requires changes at the Tkinter C-extension level (Modules/_tkinter.c) or the Tk/Tcl level, rather than just Python-level changes in IDLE.
This affects not just Chinese users but also Japanese, Korean, and any user with a non-English IME on Windows. It's a common pain point for beginners who may not realize they need to switch to English input to write code.
The only single-key shortcuts defined by IDLE are unmodified function keys: F1, F5, and F6. 'Python 3.x.y documentation' and 'Search' are F1 and CTRL-F respectively. I am pretty sure that IDLE has nothing to do with mapping unmodified p and r to those bindings. So I removed topic-idle.
The Keybindings section of the IDLE doc lists bindings that come with tk Text widgets. I discovered another one: given "p|r" where '|' is the cursor, ctrl-t results in "rp|". IDLE binds ctrl-p to 'print current window'; ctrl-r does nothing I could detect.
I have asked for vefifications from other East Asian Windows IME users.
Activity
9calebscript9 commentedon Nov 29, 2026
GongSunFangYun commentedon Nov 29, 2026
This affects not just Chinese users but also Japanese, Korean, and any user with a non-English IME on Windows. It's a common pain point for beginners who may not realize they need to switch to English input to write code.
picnixz commentedon Nov 29, 2026
GongSunFangYun commentedon Nov 29, 2026
GongSunFangYun commentedon Nov 29, 2026
picnixz commentedon Nov 29, 2026
GongSunFangYun commentedon Nov 29, 2026
terryjreedy commentedon Nov 29, 2026
The only single-key shortcuts defined by IDLE are unmodified function keys: F1, F5, and F6. 'Python 3.x.y documentation' and 'Search' are F1 and CTRL-F respectively. I am pretty sure that IDLE has nothing to do with mapping unmodified p and r to those bindings. So I removed topic-idle.
The Keybindings section of the IDLE doc lists bindings that come with tk Text widgets. I discovered another one: given "p|r" where '|' is the cursor, ctrl-t results in "rp|". IDLE binds ctrl-p to 'print current window'; ctrl-r does nothing I could detect.
I have asked for vefifications from other East Asian Windows IME users.
StanFromIreland commentedon Nov 29, 2026
Duplicate of #125349. This is a Tk bug, which Serhiy fixed upstream.
GongSunFangYun commentedon Nov 29, 2026
Python 3.15.1 (tags/v3.15.1:c37e74c, Oct 21 2026, 06:24:08) [MSC v.1951 64 bit (AMD64)] on win32However, Python 3.15 and earlier versions still use Tcl/Tk libraries that have not been patched in real time (default behavior).