python / python/cpython

The New REPL Does Not Load My Command History

未关闭
#120,766 8 条评论 1 个 reaction 已指派 1 人 在 GitHub 查看

@ambv 已经在做这个了。

开始于 2024年6月21日。

3.13 3.14 stdlib topic-repl type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

Bug description:

In my ~/.pystartup I have the following code:

import atexit
import os
import readline
import rlcompleter

historyPath = os.path.expanduser("~/.pyhistory")

def save_history(historyPath=historyPath):
    import readline
    readline.write_history_file(historyPath)

if os.path.exists(historyPath):
    readline.read_history_file(historyPath)

atexit.register(save_history)
del os, atexit, readline, rlcompleter, save_history, historyPath

This is something I've been using for years. With this startup file, I can enter the REPL and immediately up-arrow to scroll through the commands I used the last time I used the REPL.

With the new REPL there are two related things going wrong:

  • my command history is not loaded (when I immediately up-arrow, it does nothing)
  • my command history is not saved in my .pyhistory file (the file is touched but not otherwise modified)

CC @ambv, @pablogsal

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。