-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
The new REPL floods the output when stdout is a broken pipe #142948
Copy link
Copy link
Closed as not planned
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
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
Linked PRs