GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-141295: Persist pdb command history with PyREPL by gaogaotiantian · Pull Request #159969 · python/cpython

Conversation

@gaogaotiantian

@gaogaotiantian gaogaotiantian commented Oct 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Closes #141295.

Persist pdb command history when using PyREPL. Load history when the debugger input is initialized and append commands after each input, so a later pdb process can recall them with the arrow keys.

Add PYTHON_HISTORY_PDB to override the history path. Otherwise, use PYTHON_HISTORY with .pdb appended, falling back to ~/.python_history.pdb. Ignore environment overrides under -E and -I.

Add a PTY test that saves commands and recalls them in a second process, and isolate the PyREPL debugger tests with a shared temporary history file. Update the documentation, environment-variable help, and NEWS.

Why a new env var / file instead of using the existing history file?

pdb and the python interactive shell has different commands - the commands executed in pdb may not be executable in the interactive shell. Mixing the history for these might not be the best idea.

Also, code wise, pdb and _pyrepl are using two different readers (because they have different colorization mechanism), so the history living in memory is different. Mixing the two histories in one file is also technically challenging in an unnecessary way.

Validation:

  • ./python.exe -m test test_pdb passes.
  • The history integration test was also run directly in a terminal, including after another PyREPL test, with an inherited user-history path verified unchanged. The normal class is skipped with this build's libedit backend.
  • git diff --check passes.
  • Issue: Save pdb Line History Between Runs #141295

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gaogaotiantian
pythongh-141295: Persist pdb command history with PyREPL
18aa905
@gaogaotiantian
gaogaotiantian requested review from FFY00 and ericsnowcurrently as code owners October 20, 2026 22:38
@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 20, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Oct 20, 2026
Save pdb Line History Between Runs #141295
Open
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 20, 2026
@read-the-docs-community

read-the-docs-community Bot commented Oct 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35368100 | 📁 Comparing cbccad8 against main (80040b6)

  🔍 Preview build  

72 files changed · + 1 added · ± 71 modified

+ Added

  • c-api/pyexpat.html

± Modified

  • license.html
  • builtins/functions.html
  • c-api/code.html
  • c-api/conversion.html
  • c-api/descriptor.html
  • c-api/dict.html
  • c-api/exceptions.html
  • c-api/file.html
  • c-api/function.html
  • c-api/hash.html
  • and 61 more...
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gaogaotiantian

gaogaotiantian commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

Hi @hugovk and @hauntsaninja , could you take a look at this as you worked on #13208?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gaogaotiantian
Merge branch 'main' into pdb-history
cbccad8
@gaogaotiantian

gaogaotiantian commented Oct 23, 2026

Copy link
Copy Markdown
Member Author

@iritkatriel do you mind taking a quick look at this? Is there anyone I should consult first when I'm trying to add a new env var and history file to CPython?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel

iritkatriel commented Oct 24, 2026

Copy link
Copy Markdown
Member

I think @pablogsal and @ambv did similar stuff for the python repl.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review type-feature A feature request or enhancement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Save pdb Line History Between Runs

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@gaogaotiantian @iritkatriel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.