python / python/cpython

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

オープン
#127,947 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

PyREPL の Windows KEY_EVENT_RECORD 入力処理から始め、繰り返されるキーイベントがどのように処理されるかを調べます。dead-key キーボードレイアウトを使用して Windows Terminal で dead-key の動作を再現し、その後、wRepeatCount が 1 より大きいイベントによって期待どおりの繰り返し文字が生成されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
cli, operating-systems
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。