-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Description
Bug report
Bug description:
The new REPL assumes that writing to stdout would never raise BrokenPipeError, so it doesn't guard against it.
In some rare scenarios this can cause spurious output flood.
I’m attaching a short video demonstrating the issue. An example case of broken pipe is when the stdout is piped to xargs, and xargs receives SIGINT, breaking pipe. There might exist some more realistic scenarios though, perhaps.
Note: the video contains rapidly changing on‑screen text, which may be uncomfortable for some viewers (e.g. those with photosensitivity).
Screencast.From.2025-12-18.18-07-37.mp4
(This would loop forever -- I've pressed Ctrl+C and then Ctrl+C again)
A way to workaround the problem is to disable the new REPL entirely (i.e., fall back to basic REPL) if the stdout is non-interactive -- this is what I'm proposing in the PR. The new REPL's functions emulating curses are complex and I didn't want to further complicate them just to cover extremely rare edge cases.
If that's too aggressive, we could just guard against the broken pipe error when writing to stdout.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux