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..9be261abdd2898 100644 --- a/Lib/test/test_pyrepl/test_unix_console.py +++ b/Lib/test/test_pyrepl/test_unix_console.py @@ -368,6 +368,26 @@ 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() + + _os_write.reset_mock() + + console._sigcont_handler(signal.SIGCONT, None) + self.assertTrue(reader.handle1(block=False)) + + 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): # gh-128636 console = UnixConsole(term="xterm") diff --git a/Misc/NEWS.d/next/Library/2026-08-13-09-19-29.gh-issue-155432.SXvWk4.rst b/Misc/NEWS.d/next/Library/2026-08-13-09-19-29.gh-issue-155432.SXvWk4.rst new file mode 100644 index 00000000000000..8e4a4cbae0a170 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-08-13-09-19-29.gh-issue-155432.SXvWk4.rst @@ -0,0 +1,2 @@ +Re-print the PyREPL prompt after the interpreter is resumed with ``fg`` +following suspension with ``Ctrl-Z``.