-
-
Couldn't load subscription status.
- Fork 33.2k
gh-140482: Preserve and restore stty echo as a test environment
#140519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
stty echo as a test environmentstty echo as a test environment
stty echo as a test environmentstty echo as a test environment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few style nits and a question, but LGTM.
Misc/NEWS.d/next/Tests/2025-10-23-16-39-49.gh-issue-140482.ZMtyeD.rst
Outdated
Show resolved
Hide resolved
|
Thanks @warsaw for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…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
…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. |
|
So which tests fail with this additional check? |
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.