python / python/cpython

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

Abierto
#117,704 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza reproduciendo el problema con el script de inicio de Python, pathlib, readline.read_init_file y un archivo .editrc que contenga comentarios de más de 20 caracteres en libedit. Sigue la ruta de readline.read_init_file y confirma que se aplican las configuraciones de .editrc cuando se importa pathlib; la reproducción se considera completada cuando deja de fallar y el comportamiento existente permanece intacto.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
cli
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.