Skip to content

Commit ae66ca5

Browse files
gh-141998: Fix input being colorized in the pyrepl when reading via readline
1 parent 5ec03cf commit ae66ca5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Lib/_pyrepl/readline.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,12 @@ def input(self, prompt: object = "") -> str:
374374
prompt_str = str(prompt)
375375
reader.ps1 = prompt_str
376376
sys.audit("builtins.input", prompt_str)
377-
result = reader.readline(startup_hook=self.startup_hook)
377+
try:
378+
can_colorize = reader.can_colorize
379+
reader.can_colorize = False
380+
result = reader.readline(startup_hook=self.startup_hook)
381+
finally:
382+
reader.can_colorize = can_colorize
378383
sys.audit("builtins.input/result", result)
379384
return result
380385

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixes syntax highlighting/colorization being applied to input that is read
2+
in via the pyrepl readline interface

0 commit comments

Comments
 (0)