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
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionLib/pdb.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -888,7 +888,7 @@ def _exec_in_closure(self, source, globals, locals):
locals.update(pdb_eval["write_back"])
eval_result=pdb_eval["result"]
ifeval_resultisnotNone:
print(repr(eval_result))
self.message(repr(eval_result))

returnTrue

Expand Down
28 changes: 28 additions & 0 deletionsLib/test/test_remote_pdb.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1441,6 +1441,34 @@ def test_multi_line_commands(self):
self.assertIn("Function returned: 42", stdout)
self.assertEqual(process.returncode, 0)

def test_exec_in_closure_result_uses_pdb_stdout(self):
"""
Expression results executed via _exec_in_closure() should be written
to the debugger output stream (pdb stdout), not to sys.stdout.
"""
self._create_script()
process, client_file = self._connect_and_get_client_file()

with kill_on_error(process):
self._read_until_prompt(client_file)

self._send_command(client_file, "(lambda: 123)()")
messages = self._read_until_prompt(client_file)
result_msg = "".join(msg.get("message", "") for msg in messages)
self.assertIn("123", result_msg)

self._send_command(client_file, "sum(i for i in (1, 2, 3))")
messages = self._read_until_prompt(client_file)
result_msg = "".join(msg.get("message", "") for msg in messages)
self.assertIn("6", result_msg)

self._send_command(client_file, "c")
stdout, _ = process.communicate(timeout=SHORT_TIMEOUT)

self.assertNotIn("\n123\n", stdout)
self.assertNotIn("\n6\n", stdout)
self.assertEqual(process.returncode, 0)


def _supports_remote_attaching():
PROCESS_VM_READV_SUPPORTED = False
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Fixed a bug in :mod:`pdb` where expression results were not sent back to remote client.
Loading

[8]ページ先頭

©2009-2026 Movatter.jp