python / python/cpython

REPL import tab completion moves cursor backward

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

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

pending stdlib topic-repl type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:

When tab completing ambiguous imports in the Python REPL, pressing tab once will insert the longest unambiguous completion and display "[ complete but not unique ]". Pressing tab a second time will show all the possibilities.

In Ghostty, when you press tab the second time, the cursor moves one cell to the left. This happens with cursor-style = bar as well as the default block cursor.

I reproduced this in Ghostty with both fish shell and bash. I could not reproduce this in Zed's integrated terminal (with a bar cursor) or Terminal.app (with a block cursor).

Originally posted by @injust in https://github.com/ghostty-org/ghostty/discussions/11131


I initially reported this issue to Ghostty, and the maintainer's response was:

This is a bug in Terminal.app in how it handles CUB with the cursor in the pending wrap state. Or, a bug in Python's readline in how it calculates the amount to move the cursor back. Your bug reproduces on xterm, and Ghostty matches xterm. Specifically, CUB moves exactly n cells back ignoring pending wrap in xterm and Ghostty matches this. In Terminal.app, CUB subtracts one when it is in the pending wrap state.

Since the bug reproduces in both Ghostty and xterm, it might be a bug in the Python REPL.

I captured the bug in this asciicast: https://github.com/user-attachments/files/25683940/ascii.cast.json

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs
  • gh-145727

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Python REPL の readline import 補完の挙動から始め、リンクされた asciicast を確認して、2回目のタブ操作でカーソルが移動する現象を再現する。ターミナルで曖昧な補完の前後のカーソル位置を比較する。繰り返しタブ補完を行ってもカーソルが後方に移動しなくなれば完了。

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

評価

技術スタック
python
領域
cli
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

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

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