From af1032f65a4ce593628b1615deb7422e150ac569 Mon Sep 17 00:00:00 2001 From: Bhuvansh Kataria Date: Thu, 13 Aug 2026 09:10:48 +0000 Subject: [PATCH 1/4] gh-155432: redraw PyREPL after SIGCONT --- Lib/_pyrepl/unix_console.py | 1 + Lib/test/test_pyrepl/test_unix_console.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/Lib/_pyrepl/unix_console.py b/Lib/_pyrepl/unix_console.py index 8edd1c36a7232d..0c11aac4ea95ae 100644 --- a/Lib/_pyrepl/unix_console.py +++ b/Lib/_pyrepl/unix_console.py @@ -277,6 +277,7 @@ def _my_getstr(cap: str, optional: bool = False) -> bytes | None: def _sigcont_handler(self, signum, frame): self.restore() self.prepare() + self.event_queue.insert(Event("resize", "")) def __read(self, n: int) -> bytes: return os.read(self.input_fd, n) diff --git a/Lib/test/test_pyrepl/test_unix_console.py b/Lib/test/test_pyrepl/test_unix_console.py index 2fc8398923cbf3..d0d726ba144dad 100644 --- a/Lib/test/test_pyrepl/test_unix_console.py +++ b/Lib/test/test_pyrepl/test_unix_console.py @@ -368,6 +368,21 @@ def same_console(events): console.restore() con.restore() + def test_sigcont_redraws_prompt(self, _os_write): + console = unix_console([]) + console.get_event = UnixConsole.get_event.__get__(console) + reader = self._prepare_reader_with_prompts(console) + reader.ps1 = reader.ps2 = ">>> " + reader.ps3 = reader.ps4 = "... " + reader.prepare() + reader.refresh() + + console._sigcont_handler(signal.SIGCONT, None) + reader.handle1(block=False) + + self.assertEqual(reader.screen, [">>> "]) + console.restore() + def test_getheightwidth_with_invalid_environ(self, _os_write): # gh-128636 console = UnixConsole(term="xterm") From 1add1db7d7b0f102634cb607db60e212ce868e2e Mon Sep 17 00:00:00 2001 From: Bhuvansh Kataria Date: Thu, 13 Aug 2026 09:15:42 +0000 Subject: [PATCH 2/4] gh-155432: add NEWS entry --- .../6afad9cc-730f-4b52-a3c1-95ac36e91146.gh-issue-155432.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/6afad9cc-730f-4b52-a3c1-95ac36e91146.gh-issue-155432.rst diff --git a/Misc/NEWS.d/next/Library/6afad9cc-730f-4b52-a3c1-95ac36e91146.gh-issue-155432.rst b/Misc/NEWS.d/next/Library/6afad9cc-730f-4b52-a3c1-95ac36e91146.gh-issue-155432.rst new file mode 100644 index 00000000000000..36cae572e58303 --- /dev/null +++ b/Misc/NEWS.d/next/Library/6afad9cc-730f-4b52-a3c1-95ac36e91146.gh-issue-155432.rst @@ -0,0 +1,2 @@ +Re-print the PyREPL prompt after the interpreter is resumed with +``fg`` following suspension with ``Ctrl-Z``. From 97dc8c017c533cf079c67c64203b5f617cabe172 Mon Sep 17 00:00:00 2001 From: Bhuvansh Kataria Date: Thu, 13 Aug 2026 09:21:33 +0000 Subject: [PATCH 3/4] gh-155432: add NEWS entry --- ...432.rst => 2026-08-13-09-19-29.gh-issue-155432.SXvWk4.rst} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename Misc/NEWS.d/next/Library/{6afad9cc-730f-4b52-a3c1-95ac36e91146.gh-issue-155432.rst => 2026-08-13-09-19-29.gh-issue-155432.SXvWk4.rst} (58%) diff --git a/Misc/NEWS.d/next/Library/6afad9cc-730f-4b52-a3c1-95ac36e91146.gh-issue-155432.rst b/Misc/NEWS.d/next/Library/2026-08-13-09-19-29.gh-issue-155432.SXvWk4.rst similarity index 58% rename from Misc/NEWS.d/next/Library/6afad9cc-730f-4b52-a3c1-95ac36e91146.gh-issue-155432.rst rename to Misc/NEWS.d/next/Library/2026-08-13-09-19-29.gh-issue-155432.SXvWk4.rst index 36cae572e58303..8e4a4cbae0a170 100644 --- a/Misc/NEWS.d/next/Library/6afad9cc-730f-4b52-a3c1-95ac36e91146.gh-issue-155432.rst +++ b/Misc/NEWS.d/next/Library/2026-08-13-09-19-29.gh-issue-155432.SXvWk4.rst @@ -1,2 +1,2 @@ -Re-print the PyREPL prompt after the interpreter is resumed with -``fg`` following suspension with ``Ctrl-Z``. +Re-print the PyREPL prompt after the interpreter is resumed with ``fg`` +following suspension with ``Ctrl-Z``. From 6561b5feb6d541c7307f00f1cc9600f45ad4d7fe Mon Sep 17 00:00:00 2001 From: Bhuvansh Kataria Date: Wed, 7 Oct 2026 20:12:00 +0000 Subject: [PATCH 4/4] gh-155432: strengthen SIGCONT prompt test --- Lib/test/test_pyrepl/test_unix_console.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_pyrepl/test_unix_console.py b/Lib/test/test_pyrepl/test_unix_console.py index d0d726ba144dad..9be261abdd2898 100644 --- a/Lib/test/test_pyrepl/test_unix_console.py +++ b/Lib/test/test_pyrepl/test_unix_console.py @@ -377,10 +377,15 @@ def test_sigcont_redraws_prompt(self, _os_write): reader.prepare() reader.refresh() + _os_write.reset_mock() + console._sigcont_handler(signal.SIGCONT, None) - reader.handle1(block=False) + self.assertTrue(reader.handle1(block=False)) - self.assertEqual(reader.screen, [">>> "]) + self.assertIn( + b">>> ", + b"".join(c.args[1] for c in _os_write.mock_calls), + ) console.restore() def test_getheightwidth_with_invalid_environ(self, _os_write):