cpython/Lib/_pyrepl
Harjoth Khara 46ee3580c0
gh-152907: Restore cooked output flags around the input hook in the new REPL (#153389)
* gh-152907: Restore cooked output flags around the input hook in the new REPL

pyrepl clears OPOST for its own cursor rendering but calls PyOS_InputHook
from inside the raw-mode read loop, so output written by an input hook
(GUI toolkit event loops, and any warning/traceback/print they emit) is
emitted with bare '\n' and no '\r'.  Restore the terminal's saved output
flags around the hook call and re-enter raw mode afterwards; only oflag is
toggled so ECHO/ICANON stay off at the prompt.

* Skip the input-hook test on platforms without pty devices

The Emscripten buildbot has the pty module but no pty devices, so
pty.openpty() raises OSError("out of pty devices").  Guard the test
class the same way Lib/test/test_pty.py does.

* Propagate the input hook's return value and drop the sleep from the test

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Trim comments

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Observe the hook's output synchronously instead of via the reader thread

The reader thread no longer feeds any assertion: the hook drains the pty
master itself, so the check is an exact comparison. A drainer is still
needed for restore(), which writes before switching modes.

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-24 17:01:19 +01:00
..
__init__.py
__main__.py
_module_completer.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
_threading_handler.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
base_eventqueue.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
commands.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
completing_reader.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
console.py gh-69919: Catch all compile errors in the code module, pyrepl and IDLE (GH-157585) 2026-09-23 23:04:13 +03:00
content.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
fancy_termios.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
fancycompleter.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
historical_reader.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
input.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
keymap.py
layout.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
main.py gh-127960 Fix the REPL to set the correct namespace by setting the correct __main__ module (gh-134275) 2025-05-22 02:18:00 +02:00
mypy.ini gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
pager.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
reader.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
readline.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
render.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
simple_interact.py gh-69919: Catch all compile errors in the code module, pyrepl and IDLE (GH-157585) 2026-09-23 23:04:13 +03:00
terminfo.py
trace.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
types.py gh-148105: _pyrepl: switch console refresh to structured rendered screens (#146584) 2026-04-08 23:42:26 +01:00
unix_console.py gh-152907: Restore cooked output flags around the input hook in the new REPL (#153389) 2026-09-24 17:01:19 +01:00
unix_eventqueue.py gh-135621: Remove dependency on curses from PyREPL (GH-136758) 2025-07-21 11:57:34 +02:00
utils.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
windows_console.py gh-149985: Remove future annotations and if TYPE_CHECKING in pyrepl (#149992) 2026-08-25 16:48:54 -07:00
windows_eventqueue.py