mirror of
https://github.com/python/cpython.git
synced 2026-04-14 07:41:00 +00:00
[3.14] gh-136924: Suspend REPL colorizing when in a REPL interactive command (GH-136926) (GH-143390)
(cherry picked from commit 2c39b9d2f2)
Co-authored-by: Olga Matoula <olgamatoula@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
661083297f
commit
6eafcaee64
3 changed files with 13 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
The interactive help mode in the :term:`REPL` no longer incorrectly syntax
|
||||
highlights text input as Python code. Contributed by Olga Matoula.
|
||||
Loading…
Add table
Add a link
Reference in a new issue