{{ message }}
gh-140482: Preserve and restore stty echo as a test environment - #140519
Merged
Merged
Conversation
stty echo as a test environmentstty echo as a test environment
stty echo as a test environmentstty echo as a test environment
zware
approved these changes
Oct 24, 2025
zware
left a comment
Member
There was a problem hiding this comment.
A few style nits and a question, but LGTM.
vstinner
reviewed
Oct 24, 2025
zware
approved these changes
Oct 24, 2025
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Oct 24, 2025
…nt (pythonGH-140519) (cherry picked from commit b3c713a) Co-authored-by: Barry Warsaw <barry@python.org> pythongh-140482: Restore `stty echo` as a test environment
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Oct 24, 2025
…nt (pythonGH-140519) (cherry picked from commit b3c713a) Co-authored-by: Barry Warsaw <barry@python.org> pythongh-140482: Restore `stty echo` as a test environment
|
GH-140562 is a backport of this pull request to the 3.14 branch. |
|
GH-140563 is a backport of this pull request to the 3.13 branch. |
Member
|
So which tests fail with this additional check? |
Member
I reply to myself, Barry already wrote in the issue:
So test_ssl may be the guilty test. At least, we will know which tests change the terminal to |
Member
Author
colesbury
added a commit
to colesbury/cpython
that referenced
this pull request
Dec 2, 2025
…nvironment (python#140519)" Reverts python#140519 This reverts commit b3c713a. Reason: The PR leads to spurious "ENV CHANGED" failures when running tests in an interactive terminal.
StanFromIreland
pushed a commit
to StanFromIreland/cpython
that referenced
this pull request
Dec 6, 2025
…nt (python#140519) pythongh-140482: Restore `stty echo` as a test environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The test suite sometimes turns off terminal echo after it completes. As far as I can tell, it's completely random and probably caused by tests that don't (or can't!) fully clean up after themselves. After implementing this fix and testing it many times with
make testandmake quicktest, I see a common set of tests that it happens in, but no real rhyme or reason.This patch just saves and restores
termios.ECHOas a saved test environment and in lots of local testing it works perfectly. Yeah, it's just an annoyance but as #140480 says, this has been annoying me for many releases. Thanks to @zware for suggesting a test environment in my abandoned #140482 PR.I recommend backporting to all active non-security branches as it will help and there should be no risk involved. One caveat is that I did have to change the signature and semantics of
try_get_module()because if the requested module is not already imported,sys.modules[name]will fail, and sincetermiosisn't generally imported,try_get_module()would be unhelpful otherwise. The alternative is to importtermiosat the top of the module so it's always available, but as no other saved test environment seems to do that, and this environment is global rather than tied to a specific test, I thought this was the better approach. Suggestions welcome.