-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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. |
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.