python / python/cpython

PyREPL does not handle `wRepeatCount` on Windows, causing incorrect 'dead key' behavior

未关闭
#127,947 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

OS-windows topic-repl type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

Bug description:

PyREPL (introduced in Python 3.13) fails to account for the wRepeatCount field in the KEY_EVENT_RECORD on Windows, resulting in incorrect behavior when keys are pressed repeatedly in the REPL. This issue is reproducible in the Windows Terminal on Windows 10 or 11, specifically when using a keyboard layout with dead keys (e.g., US International layout).

This issue can be bothering as it messes with muscle memory when typing quotes in the new PyREPL (which otherwise is AWESOME!)

Steps to Reproduce:
  1. Open Python 3.13+ in the Windows Terminal (NOT in an older conhost.exe-based terminal) on Windows 10 or 11.
  2. Use a keyboard layout with dead keys, such as the US International layout.
  3. Type a dead key character (e.g., ', ", ^, `, or ~) into the REPL input.
    • Expected behavior: No character is typed, as the dead key is waiting for the next key to combine.
    • Actual behavior: No character is typed, which is correct.
  4. Type the same dead key again.
    • Expected behavior: The character corresponding to the dead key should be typed twice.
    • Actual behavior: The character is only typed once.
Root Cause:

The Windows Terminal sends a single key event with wRepeatCount == 2 when a key is pressed repeatedly. PyREPL does not check the wRepeatCount value, so the REPL only processes the key press once. In contrast, conhost.exe-based terminals send two separate key events for the repeated key press, causing the REPL to handle the input correctly in those environments.

Desired Fix:

Modify PyREPL to correctly handle the wRepeatCount value in the KEY_EVENT_RECORD. When wRepeatCount > 1, the corresponding key should be processed the specified number of times to ensure correct handling of repeated key presses.

CPython versions tested on:

3.13, 3.14, CPython main branch

Operating systems tested on:

Windows

Linked PRs
  • gh-127948

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 PyREPL 的 Windows KEY_EVENT_RECORD 输入处理开始,检查重复按键事件是如何处理的。在使用 dead-key 键盘布局的 Windows Terminal 中复现 dead-key 行为,然后验证 wRepeatCount 大于一的事件会生成预期的重复字符。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
cli, operating-systems
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
描述清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。