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 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

type-bug
主要語言
Python
星號
77.2k
分支
35.9k
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. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 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 摘要。