Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readline.set_history_length results in unreadable history files #281

Open
encukou opened this issue Jul 18, 2024 · 0 comments
Open

readline.set_history_length results in unreadable history files #281

encukou opened this issue Jul 18, 2024 · 0 comments

Comments

@encukou
Copy link

encukou commented Jul 18, 2024

Hello,
Writing a history file after a call to readline.set_history_length results in an unreadable history file. For example, with cpython-3.12.4+20240713-x86_64-unknown-linux-gnu-install_only.tar.gz:

import readline
import os


readline.add_history("first line")
readline.add_history("second line")
readline.add_history("third line")

readline.set_history_length(2)
readline.write_history_file('historyfile.tmp')
try:
    readline.read_history_file('historyfile.tmp')
finally:
    os.remove('historyfile.tmp')

gives me a traceback on the read_history_file:

Traceback (most recent call last):
  File "/script.py", line 12, in <module>
    readline.read_history_file('historyfile.tmp')
OSError: [Errno 22] Invalid argument

This might be a conflict/incompatibility between editline and a history library that doesn't work with editline's _HiStOrY_V2_ format.

I've added a test to CPython that should fail in this case. I don't know what more I can do on the CPython side.

The same “Invalid argument” error happens when trying to read a history file produced with GNU readline. This can affect users switching from some earlier standalone builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant