]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-154467: Fix empty (Pdb) prompt when attaching to a process with pdb -p (#154469)
authorŁukasz Langa <lukasz@langa.pl>
Mon, 27 Jul 2026 20:45:40 +0000 (13:45 -0700)
committerGitHub <noreply@github.com>
Mon, 27 Jul 2026 20:45:40 +0000 (13:45 -0700)
commit1ec56076642091c446ec95afcf166bb4f185f0b7
treefb0723a9195de12eb1b07b3cd1a1cc679d223fbd
parent0284ce81c9615432473abac709d5b261a49399ad
gh-154467: Fix empty (Pdb) prompt when attaching to a process with pdb -p (#154469)

_PdbServer inherits _cmdloop, which wraps cmdloop() in
_maybe_use_pyrepl_as_stdin(). That context manager blanks self.prompt to ''
so that a local pyrepl draws the prompt itself. The remote server, however,
never reads from a local pyrepl -- it transmits self.prompt to the client
over the socket -- so the blanking made it send an empty prompt whenever the
target process had a pyrepl-capable terminal (pyrepl_input is set).

Override _maybe_use_pyrepl_as_stdin() in _PdbServer to a no-op, keeping the
real prompt. Add an integration test that attaches to a target running under
a pty, so PyREPL is genuinely enabled inside it, and asserts the transmitted
prompt is "(Pdb) ".

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Lib/pdb.py
Lib/test/test_remote_pdb.py
Misc/NEWS.d/next/Library/2026-07-22-12-59-26.gh-issue-154467.AA9w1D.rst [new file with mode: 0644]