Skip to content

gh-154467: Fix empty (Pdb) prompt when attaching to a process with pdb -p#154469

Open
ambv wants to merge 1 commit into
python:mainfrom
ambv:gh-154467-pdb-remote-prompt
Open

gh-154467: Fix empty (Pdb) prompt when attaching to a process with pdb -p#154469
ambv wants to merge 1 commit into
python:mainfrom
ambv:gh-154467-pdb-remote-prompt

Conversation

@ambv

@ambv ambv commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

_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) ".

This was broken by gh-145379.

…ith pdb -p

_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>
@ambv
ambv force-pushed the gh-154467-pdb-remote-prompt branch from 04ca7e3 to 98a07de Compare July 22, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant