gh-143874: Fix pdb expression result output stream in _exec_in_closure() #143875
gh-143874: Fix pdb expression result output stream in _exec_in_closure() #143875gaogaotiantian merged 6 commits intopython:mainfrom
_exec_in_closure() #143875Conversation
Fixes an issue where results of expressions executed via `_exec_in_closure()` were written to `sys.stdout` instead of the debugger output stream. Adds a regression test to ensure expression results are consistently emitted via pdb.stdout. Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
|
I think the current test case doesn't actually test the remote debug mode. We need add some tests in cpython/Lib/test/test_remote_pdb.py Lines 832 to 833 in c461aa9 |
|
Let's add some tests like this: class RemotePdbTestCase(unittest.TestCase):
...
def test_remote_closure_exec(self):
self.pdb._exec_in_closure('(lambda: 123)()', {}, {})
outputs = self.sockfile.get_output()
messages = [o['message'].strip() for o in outputs if 'message' in o]
self.assertIn("123", messages) |
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. <(_ _)> |
|
The issue is real 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 socketThank you for helping identify the RCA and clarifying the underlying cause–and–effect relationship. |
|
Thank you for the contribution! |
|
Thanks @hyongtao-code for the PR, and @gaogaotiantian for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…losure()` (pythonGH-143875) (cherry picked from commit e66597d) Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com>
|
GH-144061 is a backport of this pull request to the 3.14 branch. |
Fixes an issue where results of expressions executed via
_exec_in_closure()were written tosys.stdoutinstead of the debugger output stream. Adds a regression test to ensure expression results are consistently emitted viapdb.stdout.