diff --git a/news/13072.trivial.rst b/news/13072.trivial.rst new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/pip/_internal/utils/logging.py b/src/pip/_internal/utils/logging.py index 41f6eb51a26..be17add5dde 100644 --- a/src/pip/_internal/utils/logging.py +++ b/src/pip/_internal/utils/logging.py @@ -137,12 +137,19 @@ def __rich_console__( yield Segment("\n") +class PipConsole(Console): + def on_broken_pipe(self) -> None: + # Reraise the original exception, rich 13.8.0+ exits by default + # instead, preventing our handler from firing. + raise + + class RichPipStreamHandler(RichHandler): KEYWORDS: ClassVar[Optional[List[str]]] = [] def __init__(self, stream: Optional[TextIO], no_color: bool) -> None: super().__init__( - console=Console(file=stream, no_color=no_color, soft_wrap=True), + console=PipConsole(file=stream, no_color=no_color, soft_wrap=True), show_time=False, show_level=False, show_path=False,