Skip to content

New REPL - readline module does not save history with write_history_fileΒ #130938

@devcode11

Description

@devcode11

Bug report

Bug description:

When using new REPL in Python 13, the readline module does not write history to the files correctly.
I have checked this issue on both my host system, as well as python:alpine container from docker.

Using PYTHON_BASIC_REPL=1 no longer causes this issue.

Expected
hist.txt file contains the saved commands.

Actual
hist.txt file is empty. Note that .python_history file does save and load history correctly.

/ # python -i
Python 3.13.2 (main, Feb 14 2025, 19:28:41) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import readline
>>> print('abc')
abc
>>> readline.get_current_history_length()
0
>>> readline.set_history_length(100)
>>> readline.get_current_history_length()
0
>>> readline.write_history_file('hist.txt')
>>> 
/ # cat hist.txt 
/ # cat ~/.python_history 
import readline
print('abc')
readline.get_current_history_length()
readline.set_history_length(100)
readline.get_current_history_length()
readline.write_history_file('hist.txt')
/ # 

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions