Skip to content

Commit 3b1f943

Browse files
committed
Disable Rich's repr highlighter on the log path
Log messages are printed with markup=False so square brackets in interpolated text are not treated as Rich markup. The repr highlighter still restyled brackets and numbers inside the message, so on a colour-capable terminal an error such as "[Errno 8]" came out with ANSI codes spliced into it. Set highlight=False on the same call. This fixes test_bracketed_error_text_prints_verbatim, which currently fails on main.
1 parent b710c29 commit 3b1f943

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎plain2code_console.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ def _log_and_print(self, level, base_style, args, color, kwargs):
6767
logger.log(level, " ".join(map(str, args)), extra={"log_color": color})
6868
style = base_style + Style(color=color) if color else base_style
6969
# Log messages must render exactly as logged: don't interpret square brackets
70-
# in interpolated content (error texts, file names) as Rich markup.
70+
# in interpolated content (error texts, file names) as Rich markup, and don't
71+
# let the repr highlighter restyle brackets and numbers inside them.
7172
kwargs.setdefault("markup", False)
73+
kwargs.setdefault("highlight", False)
7274
super().print(*args, **kwargs, style=style)
7375

7476
def print_list(self, items, style=None):

0 commit comments

Comments
 (0)