From 13acb60fac6d96363008f9d5c0257ce1656cf68b Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Sat, 15 Nov 2025 22:03:25 -0800 Subject: [PATCH 1/2] Check stdin instead of stdout for use_rawinput in pdb --- Lib/pdb.py | 4 ++-- Lib/test/test_pdb.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Lib/pdb.py b/Lib/pdb.py index b799a113503502..2a168252f9f326 100644 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -346,8 +346,8 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None, bdb.Bdb.__init__(self, skip=skip, backend=backend if backend else get_default_backend()) cmd.Cmd.__init__(self, completekey, stdin, stdout) sys.audit("pdb.Pdb") - if stdout: - self.use_rawinput = 0 + if stdin: + self.use_rawinput = False self.prompt = '(Pdb) ' self.aliases = {} self.displaying = {} diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 9a7d855003551a..b8ede93d7b4e0d 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -4710,6 +4710,19 @@ def test_readline_not_imported(self): self.assertNotIn("readline imported", stdout) self.assertEqual(stderr, "") + def test_alternate_stdin(self): + script = textwrap.dedent(""" + import pdb + import io + + input_data = io.StringIO("p 40 + 2\\nc\\n") + pdb.Pdb(stdin=input_data).set_trace() + """) + commands = "" + stdout, stderr = self._run_script(script, commands) + self.assertIn("42", stdout) + self.assertEqual(stderr, "") + @support.force_colorized_test_class class PdbTestColorize(unittest.TestCase): From ecf59a728ddebd197464cedfe06a7618f460a8a9 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sun, 16 Nov 2025 06:08:53 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2025-11-16-06-08-46.gh-issue-141615.--6EK3.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2025-11-16-06-08-46.gh-issue-141615.--6EK3.rst diff --git a/Misc/NEWS.d/next/Library/2025-11-16-06-08-46.gh-issue-141615.--6EK3.rst b/Misc/NEWS.d/next/Library/2025-11-16-06-08-46.gh-issue-141615.--6EK3.rst new file mode 100644 index 00000000000000..bb54e68398722f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-11-16-06-08-46.gh-issue-141615.--6EK3.rst @@ -0,0 +1 @@ +Check ``stdin`` instead of ``stdout`` for ``use_rawinput`` in :mod:`pdb`.