From 7358e2633a6cf07e143980e1e8c18d261d0a4fc9 Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Tue, 2 Dec 2025 14:50:16 -0500 Subject: [PATCH] Revert "gh-140482: Preserve and restore `stty echo` as a test environment (#140519)" Reverts https://github.com/python/cpython/pull/140519 This reverts commit b3c713a0af5f5c4b5704d8019a893a1b70eba941. Reason: The PR leads to spurious "ENV CHANGED" failures when running tests in an interactive terminal. --- Lib/test/libregrtest/save_env.py | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/Lib/test/libregrtest/save_env.py b/Lib/test/libregrtest/save_env.py index 138465012a252c..4cf1a075b30013 100644 --- a/Lib/test/libregrtest/save_env.py +++ b/Lib/test/libregrtest/save_env.py @@ -9,13 +9,6 @@ from .utils import print_warning -# Import termios to save and restore terminal echo. This is only available on -# Unix, and it's fine if the module can't be found. -try: - import termios # noqa: F401 -except ModuleNotFoundError: - pass - class SkipTestEnvironment(Exception): pass @@ -72,7 +65,6 @@ def __init__(self, test_name, verbose, quiet, *, pgo): 'shutil_archive_formats', 'shutil_unpack_formats', 'asyncio.events._event_loop_policy', 'urllib.requests._url_tempfiles', 'urllib.requests._opener', - 'stty_echo', ) def get_module(self, name): @@ -300,24 +292,6 @@ def restore_warnings_showwarning(self, fxn): warnings = self.get_module('warnings') warnings.showwarning = fxn - def get_stty_echo(self): - termios = self.try_get_module('termios') - if not os.isatty(fd := sys.__stdin__.fileno()): - return None - attrs = termios.tcgetattr(fd) - lflags = attrs[3] - return bool(lflags & termios.ECHO) - def restore_stty_echo(self, echo): - termios = self.get_module('termios') - attrs = termios.tcgetattr(fd := sys.__stdin__.fileno()) - if echo: - # Turn echo on. - attrs[3] |= termios.ECHO - else: - # Turn echo off. - attrs[3] &= ~termios.ECHO - termios.tcsetattr(fd, termios.TCSADRAIN, attrs) - def resource_info(self): for name in self.resources: method_suffix = name.replace('.', '_')