python / python/cpython

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

Ouverte
#127,947 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

OS-windows topic-repl type-bug
Langage dominant
Python
Étoiles
77.2k
Forks
35.9k
Métriques de merge des PR
Métriques de PR en attente

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par la gestion des entrées Windows KEY_EVENT_RECORD de PyREPL et examinez comment les événements de touches répétés sont traités. Reproduisez le comportement de touche morte dans Windows Terminal avec une disposition de clavier à touches mortes, puis vérifiez qu’un événement dont wRepeatCount est supérieur à un produit les caractères répétés attendus.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
cli, operating-systems
Type d'issue
Bug
Difficulté
2/5
Temps estimé
1-3 heures
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.