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) 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.