Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-143874: Fix pdb expression result output stream in_exec_in_closure()#143875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gaogaotiantian merged 6 commits intopython:mainfromhyongtao-code:fix-pdb
Jan 20, 2026

Conversation

@hyongtao-code
Copy link
Contributor

@hyongtao-codehyongtao-code commentedJan 15, 2026
edited by bedevere-appbot
Loading

Fixes an issue where results of expressions executed via_exec_in_closure() were written tosys.stdout instead of the debugger output stream. Adds a regression test to ensure expression results are consistently emitted viapdb.stdout.

cocolato reacted with thumbs up emoji
Fixes an issue where results of expressions executed via`_exec_in_closure()` were written to `sys.stdout` insteadof the debugger output stream.Adds a regression test to ensure expression results areconsistently emitted via pdb.stdout.Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
@cocolato
Copy link
Contributor

I think the current test case doesn't actually test the remote debug mode. We need add some tests intest_remote_pdb.py:

classRemotePdbTestCase(unittest.TestCase):
"""Tests for the _PdbServer class."""

@cocolato
Copy link
Contributor

cocolato commentedJan 15, 2026
edited
Loading

Let's add some tests like this:

classRemotePdbTestCase(unittest.TestCase):    ...deftest_remote_closure_exec(self):self.pdb._exec_in_closure('(lambda: 123)()', {}, {})outputs=self.sockfile.get_output()messages= [o['message'].strip()foroinoutputsif'message'ino]self.assertIn("123",messages)

@hyongtao-code
Copy link
ContributorAuthor

I think the current test case doesn't actually test the remote debug mode.

Thank you very much — I couldn’t agree more with your feedback.

Before that, I spent a long time trying to find an appropriate place for the corresponding test case, and still didn’t get it right. <(_ _)>

@gaogaotiantian
Copy link
Member

The issue is real but it's not becauseprint prints tosys.stdout. It's because remote pdb overridesself.message so we have to use that.sys.stdout is actually replaced withself.stdout in local pdb mode.

hyongtao-code reacted with laugh emojihyongtao-code reacted with heart emoji

@hyongtao-code
Copy link
ContributorAuthor

but it's not because

Totally agree. The actual execution path is:

self.message() →local pdb: print(..., file=self.stdout) → remote pdb: send over the socket

Thank you for helping identify the RCA and clarifying the underlying cause–and–effect relationship.

@gaogaotiantiangaogaotiantian merged commite66597d intopython:mainJan 20, 2026
47 checks passed
@gaogaotiantian
Copy link
Member

Thank you for the contribution!

hyongtao-code reacted with laugh emoji

@miss-islington-app
Copy link

Thanks@hyongtao-code for the PR, and@gaogaotiantian for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJan 20, 2026
…losure()` (pythonGH-143875)(cherry picked from commite66597d)Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com>
@bedevere-app
Copy link

GH-144061 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelJan 20, 2026
gaogaotiantian pushed a commit that referenced this pull requestJan 21, 2026
…closure()` (GH-143875) (#144061)gh-143874: Use self.message instead of raw print in `_exec_in_closure()`  (GH-143875)(cherry picked from commite66597d)Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com>
@hyongtao-codehyongtao-code deleted the fix-pdb branchJanuary 23, 2026 14:21
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@gaogaotiantiangaogaotiantianAwaiting requested review from gaogaotiantiangaogaotiantian is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@hyongtao-code@cocolato@gaogaotiantian

[8]ページ先頭

©2009-2026 Movatter.jp