Readline: importting `pathlib` breaks libedit `readline.read_init_file` when `.editrc`'s comments are longer than 20 characters
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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:
- Python startup script imports
pathlib .editrccontains 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
- Create a minimal python startup script with these lines:
import pathlib
import readline
readline.read_init_file('/path/to/your/editrc')
- Create a minimal
.editrcto test if it is applied (I'm using1's andbind -vhere but you can change them to whatever you want, as long as the comment exceeds 20 characters):
#11111111111111111111
bind -v
- Open your terminal and test whether Vi mode is applied.
- (extra) If you break the comment in
.editrcinto multiple lines, but not adding any1, 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the Python startup script, pathlib, readline.read_init_file, and a .editrc containing comments longer than 20 characters on libedit. Trace the readline.read_init_file path and confirm that the .editrc settings are applied when pathlib is imported; completion means the reproduction no longer fails while the existing behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100