python / python/cpython

Readline: importting `pathlib` breaks libedit `readline.read_init_file` when `.editrc`'s comments are longer than 20 characters

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

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

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

説明

Bug report

Bug description:

Environment

macOS Sonoma 14.3.1
Python 3.12.2
Libedit readline (I tested with my Linux VM and seems that the same bug doesn't appear for libreadline)

Bug Description

When reading .editrc for libedit readline with readline.read_init_file in python startup script, if both these two conditions are true:

  1. Python startup script imports pathlib
  2. .editrc contains comments with more than 21 characters

.editrc will not be applied to Python REPL. Manually typing readline.read_init_file again in REPL works though.

How to Reproduce the Bug

  1. Create a minimal python startup script with these lines:
import pathlib
import readline

readline.read_init_file('/path/to/your/editrc')
  1. Create a minimal .editrc to test if it is applied (I'm using 1's and bind -v here but you can change them to whatever you want, as long as the comment exceeds 20 characters):
#11111111111111111111

bind -v
  1. Open your terminal and test whether Vi mode is applied.
  2. (extra) If you break the comment in .editrc into multiple lines, but not adding any 1, it still breaks:
#11111111
#111111111111

bind -v

or

#1111
#1111

bind -v

#1111111
#11111
CPython versions tested on:

3.12

Operating systems tested on:

Linux, macOS

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

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

はじめの一歩

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

調査の方向性

まず、Pythonの起動スクリプト、pathlib、readline.read_init_file、およびlibedit上で20文字を超えるコメントを含む.editrcを使って問題を再現します。readline.read_init_fileの経路を追跡し、pathlibのインポート時に.editrcの設定が適用されることを確認します。再現が失敗しなくなり、既存の動作が維持されれば完了です。

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

評価

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

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

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