Skip to content

Commit a85bc9b

Browse files
committed
Fix another place where _colorize was checking the server's tty instead of the client's
1 parent 6a8f6ed commit a85bc9b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Lib/_pyrepl/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
BUILTINS = {str(name) for name in dir(builtins) if not name.startswith('_')}
2424

2525

26-
def THEME():
26+
def THEME(**kwargs):
2727
# Not cached: the user can modify the theme inside the interactive session.
28-
return _colorize.get_theme().syntax
28+
return _colorize.get_theme(**kwargs).syntax
2929

3030

3131
class Span(NamedTuple):
@@ -254,7 +254,10 @@ def is_soft_keyword_used(*tokens: TI | None) -> bool:
254254

255255

256256
def disp_str(
257-
buffer: str, colors: list[ColorSpan] | None = None, start_index: int = 0
257+
buffer: str,
258+
colors: list[ColorSpan] | None = None,
259+
start_index: int = 0,
260+
force_color=False,
258261
) -> tuple[CharBuffer, CharWidths]:
259262
r"""Decompose the input buffer into a printable variant with applied colors.
260263
@@ -295,7 +298,7 @@ def disp_str(
295298
# move past irrelevant spans
296299
colors.pop(0)
297300

298-
theme = THEME()
301+
theme = THEME(force_color=force_color)
299302
pre_color = ""
300303
post_color = ""
301304
if colors and colors[0].span.start < start_index:

Lib/pdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ def handle_command_def(self, line):
10691069
def _colorize_code(self, code):
10701070
if self.colorize:
10711071
colors = list(_pyrepl.utils.gen_colors(code))
1072-
chars, _ = _pyrepl.utils.disp_str(code, colors=colors)
1072+
chars, _ = _pyrepl.utils.disp_str(code, colors=colors, force_color=True)
10731073
code = "".join(chars)
10741074
return code
10751075

0 commit comments

Comments
 (0)