From ccff7c52f265c3ada2eb322de5462a8fa2d990ad Mon Sep 17 00:00:00 2001 From: johnslavik Date: Thu, 18 Dec 2025 18:43:37 +0100 Subject: [PATCH 1/2] Fallback to basic REPL for non-TTY stdout --- Lib/_pyrepl/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/_pyrepl/main.py b/Lib/_pyrepl/main.py index 447eb1e551e774..cbffa6860aee25 100644 --- a/Lib/_pyrepl/main.py +++ b/Lib/_pyrepl/main.py @@ -11,6 +11,8 @@ raise RuntimeError("Windows 10 TH2 or later required") if not os.isatty(sys.stdin.fileno()): raise OSError(errno.ENOTTY, "tty required", "stdin") + if not os.isatty(sys.stdout.fileno()): + raise OSError(errno.ENOTTY, "tty required", "stdout") from .simple_interact import check if err := check(): raise RuntimeError(err) From 8455a3dcf3e8fc0ef8d838ee4a03f790175b8d8c Mon Sep 17 00:00:00 2001 From: johnslavik Date: Thu, 18 Dec 2025 20:28:06 +0100 Subject: [PATCH 2/2] Add news entry --- .../Library/2025-12-18-20-27-53.gh-issue-142948.dhySDC.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2025-12-18-20-27-53.gh-issue-142948.dhySDC.rst diff --git a/Misc/NEWS.d/next/Library/2025-12-18-20-27-53.gh-issue-142948.dhySDC.rst b/Misc/NEWS.d/next/Library/2025-12-18-20-27-53.gh-issue-142948.dhySDC.rst new file mode 100644 index 00000000000000..f35fe57f7e3b9a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-12-18-20-27-53.gh-issue-142948.dhySDC.rst @@ -0,0 +1,3 @@ +The new REPL now falls back to basic REPL if stdout is non-interactive. +Previously it could flood the output if such stdout was a broken pipe. +Contributed by Bartosz Sławecki.