Skip to content

pdb: some expression results are printed to the debuggee stdout #143874

Closed

Description

@hyongtao-code

Bug report

Bug description:

In a dual-terminal / remote debugging setup, some expressions evaluated in pdb print their results to the debuggee’s stdout instead of the pdb output stream. For example, at the pdb prompt:

  • (lambda: 123)()
  • sum(i for i in (1, 2, 3))

their results appear in the remote/debuggee terminal. I have screenshots and a minimal test case demonstrating the issue.

target.py

# target.py
import os
import time

print("TARGET PID:", os.getpid(), flush=True)
print("Target is running... waiting forever.", flush=True)

while True:
    time.sleep(1)

attach.py

# attach.py
import sys
import pdb

pid = int(sys.argv[1])
print("Attaching to", pid)
pdb.attach(pid)
Image

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Jan 15, 2026
  2. added a commit that references this issue on Jan 20, 2026
  3. johnslavik commented on Jan 20, 2026

    @johnslavik
    Member

    @gaogaotiantian, do we backport #143875 or should this be closed?

  4. added a commit that references this issue on Jan 20, 2026
  5. gaogaotiantian commented on Jan 20, 2026

    @gaogaotiantian
    Member

    @johnslavik good catch! This should be backported to 3.14. I'll work on it.

  6. added a commit that references this issue on Jan 21, 2026
  7. added a commit that references this issue on Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions