python / python/cpython

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

Aperta
#117,704 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

type-bug
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il problema con lo script di avvio Python, pathlib, readline.read_init_file e un file .editrc contenente commenti più lunghi di 20 caratteri su libedit. Traccia il percorso di readline.read_init_file e conferma che le impostazioni di .editrc vengono applicate quando pathlib viene importato; la riproduzione è completa quando non fallisce più e il comportamento esistente rimane invariato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
cli
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.