Skip to content

Commit fe0925b

Browse files
authored
Merge pull request #13073 from mgorny/rich-pipe-handling
2 parents 4204359 + 099ae97 commit fe0925b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

news/13072.trivial.rst

Whitespace-only changes.

src/pip/_internal/utils/logging.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,19 @@ def __rich_console__(
137137
yield Segment("\n")
138138

139139

140+
class PipConsole(Console):
141+
def on_broken_pipe(self) -> None:
142+
# Reraise the original exception, rich 13.8.0+ exits by default
143+
# instead, preventing our handler from firing.
144+
raise BrokenPipeError() from None
145+
146+
140147
class RichPipStreamHandler(RichHandler):
141148
KEYWORDS: ClassVar[Optional[List[str]]] = []
142149

143150
def __init__(self, stream: Optional[TextIO], no_color: bool) -> None:
144151
super().__init__(
145-
console=Console(file=stream, no_color=no_color, soft_wrap=True),
152+
console=PipConsole(file=stream, no_color=no_color, soft_wrap=True),
146153
show_time=False,
147154
show_level=False,
148155
show_path=False,

0 commit comments

Comments
 (0)