Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Lib/_pyrepl/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,16 @@ def suspend(self) -> SimpleContextManager:
setattr(self, arg, prev_state[arg])
self.prepare()

@contextmanager
def suspend_colorization(self) -> SimpleContextManager:
try:
old_can_colorize = self.can_colorize
self.can_colorize = False
yield
finally:
self.can_colorize = old_can_colorize


def finish(self) -> None:
"""Called when a command signals that we're finished."""
pass
Expand Down
2 changes: 1 addition & 1 deletion Lib/_pyrepl/simple_interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def maybe_run_command(statement: str) -> bool:
command = REPL_COMMANDS[statement]
if callable(command):
# Make sure that history does not change because of commands
with reader.suspend_history():
with reader.suspend_history(), reader.suspend_colorization():
command()
return True
return False
Expand Down
Loading