GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Test suite sometimes leaves terminal in -echo · Issue #140482 · python/cpython

Test suite sometimes leaves terminal in -echo #140482

New issue
Copy link
New issue
Copy link
Closed
Closed
Test suite sometimes leaves terminal in -echo#140482
Copy link
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesOS-mactestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@warsaw
warsaw
opened on Oct 22, 2025
Issue body actions

Bug report

Bug description:

Sometimes running make test or make quicktest leaves the terminal in -echo mode, which means that after the test suite runs to completion, no keyboard input is echoed until you do a stty echo.

I've seen this in Python major version branches going back many releases, but I've just sighed, reset my terminal, and moved on. I actually spent a little bit of time trying to debug the problem, but with little success. It definitely happens in the 3.13, 3.14, and cpython (3.15 dev) branches.

It happens only intermittently, so it's not reproducible. The linked branch above has my debug code in it, but even that hasn't really helped me narrow down the offending test. The best I could come up with is test_ssl because that also fails intermittently, and when it fails, it seems to leave the terminal in -echo, but the correlation isn't perfect. I.e. in pristine main branch, you get both echo and -echo when the full suite passes, or when test_ssl fails.

Tested on macOS only, in Terminal.app and iTerm2. I've tried to reproduce it on a Linux VM, but haven't been able to. I suspect there's some timing issue where one of the terminal-munging tests runs in a subprocess and doesn't get reset at the right time.

Anyway, it's just an annoyance since the fix is easy: stty echo (which you have to type blind). Still I wanted to capture what I know in case anyone else has seen this and/or can make more progress on fixing it.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

  • gh-140482: Add some code to help debug the broken echo annoyance #140480
  • gh-140482: Preserve and restore stty echo as a test environment #140519
  • [3.14] gh-140482: Preserve and restore stty echo as a test environment (GH-140519) #140562
  • [3.13] gh-140482: Preserve and restore stty echo as a test environment (GH-140519) #140563
  • Revert "gh-140482: Preserve and restore stty echo as a test environment (#140519) #142196
  • gh-140482: Avoid changing terminal settings in test_pty #142202
  • [3.13] gh-140482: Avoid changing terminal settings in test_pty (gh-142202) #142238
  • [3.14] gh-140482: Avoid changing terminal settings in test_pty (gh-142202) #142239
Reacted by Bartosz Sławecki

Activity

  1. warsaw
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    testsTests in the Lib/test dirTests in the Lib/test dir
    OS-mac
    3.13only security fixesonly security fixes
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    on Oct 22, 2025
  2. warsaw
    added 2 commits that reference this issue on Oct 23, 2025

    pythongh-140482: Restore `stty echo` as a test environment

    7bee101

    gh-140482: Preserve and restore `stty echo` as a test environment (#1…

    b3c713a
  3. miss-islington
    added 2 commits that reference this issue on Oct 24, 2025

    pythongh-140482: Preserve and restore `stty echo` as a test environme…

    74a3d5b

    pythongh-140482: Preserve and restore `stty echo` as a test environme…

    a310931
  4. warsaw
    added 2 commits that reference this issue on Oct 24, 2025

    [3.13] gh-140482: Preserve and restore `stty echo` as a test environm…

    0f0ca07

    [3.14] gh-140482: Preserve and restore `stty echo` as a test environm…

    7545ea6
  5. warsaw
    closed this as completedon Oct 24, 2025
  6. colesbury commented on Nov 24, 2025

    @colesbury
    colesbury
    on Nov 24, 2025
    Contributor
    More actions

    I am frequently seeing warnings when running make test on Linux that stty_echo was modified. They seem to happen in random tests:

    0:00:02 load avg: 24.12 [153/497/1] test.test_future_stmt.test_future_single_import failed (env changed)
    test_floor_div_operator (test.test_future_stmt.test_future_single_import.TestFuture.test_floor_div_operator) ... ok
    test_nested_scopes (test.test_future_stmt.test_future_single_import.TestFuture.test_nested_scopes) ... ok
    test_true_div_as_default (test.test_future_stmt.test_future_single_import.TestFuture.test_true_div_as_default) ... ok
    
    ----------------------------------------------------------------------
    Ran 3 tests in 0.000s
    
    OK
    Warning -- stty_echo was modified by test.test_future_stmt.test_future_single_import
    Warning --   Before: True
    Warning --   After:  False
    
  7. colesbury
    reopened this on Nov 24, 2025
  8. colesbury commented on Nov 25, 2025

    @colesbury
    colesbury
    on Nov 25, 2025
    Contributor
    More actions

    This new behavior is much more annoying that the previous problems with -echo. Now the test suite is flaky, takes longer to run due to retries, and it's harder to tell if a local change introduced a bug because of all the spurious ENV CHANGED failures.

  9. colesbury
    added a commit that references this issue on Dec 2, 2025

    Revert "pythongh-140482: Preserve and restore `stty echo` as a test e…

    7358e26
  10. chris-eibl commented on Dec 2, 2025

    @chris-eibl
    chris-eibl
    on Dec 2, 2025
    Member
    More actions

    It definitely happens in the 3.13, 3.14, and cpython (3.15 dev) branches.

    If this happens beginning with 3.13, I have a gut feeling that it might be related to the PyRepl tests.
    FWIW, I've faced a wierd / broken terminal on Windows after running the tests until I've introduced a missing con.restore() at the end of test_multiline_ctrl_z (https://github.com/python/cpython/pull/132440/files#r2051688227) - and it depended on the order in which the tests were performed.

    Having a closer look at test_unix_console.py, in

    cpython/Lib/test/test_pyrepl/test_unix_console.py

    Lines 302 to 312 in 8801c6d

    def test_getheightwidth_with_invalid_environ(self, _os_write):
    # gh-128636
    console = UnixConsole(term="xterm")
    with os_helper.EnvironmentVarGuard() as env:
    env["LINES"] = ""
    self.assertIsInstance(console.getheightwidth(), tuple)
    env["COLUMNS"] = ""
    self.assertIsInstance(console.getheightwidth(), tuple)
    os.environ = []
    self.assertIsInstance(console.getheightwidth(), tuple)

    the console is not restored. If this happens to be the last test executed, maybe this can be an explanation for the problems you are facing?

    Also, if any of those tests fail, the console won't be restored and IMHO that could be assured with e.g. a context manager, try/finally, etc?

  11. colesbury
    added a commit that references this issue on Dec 2, 2025

    pythongh-140482: Avoid changing terminal settings in test_pty

    b30dc28
  12. colesbury commented on Dec 2, 2025

    @colesbury
    colesbury
    on Dec 2, 2025
    Contributor
    More actions

    I modified the test runner so that it polls termios.tcgetattr while the tests are running and tried to narrow things down by running the tests one at a time. On Linux, the only test that I found that disabled echo was test_pty.test_spawn_doesnt_hang. I have a tentative fix:

    • gh-140482: Avoid changing terminal settings in test_pty #142202
    Reacted by Chris Eibl
  13. warsaw commented on Dec 3, 2025

    @warsaw
    warsaw
    on Dec 3, 2025
    MemberAuthor
    More actions

    This new behavior is much more annoying that the previous problems with -echo. Now the test suite is flaky, takes longer to run due to retries, and it's harder to tell if a local change introduced a bug because of all the spurious ENV CHANGED failures.

    I'm not sure it's fair to say the test suite is flaky with the change, because I think it was always flaky, it's just that the flakiness was mostly hidden except for the annoying echo behavior. Although I didn't find the test you mentioned, I did see the env changes come up seemingly randomly, so couldn't narrow it down. Glad you were able to!

    I modified the test runner so that it polls termios.tcgetattr while the tests are running

    I didn't see that in the PR -- is it worth keeping that debugging code (maybe even commented out?).

  14. colesbury
    added a commit that references this issue on Dec 3, 2025

    gh-140482: Avoid changing terminal settings in test_pty (gh-142202)

    c0c6514
  15. miss-islington
    added 2 commits that reference this issue on Dec 3, 2025

    pythongh-140482: Avoid changing terminal settings in test_pty (python…

    cdbce17

    pythongh-140482: Avoid changing terminal settings in test_pty (python…

    979d5a3
  16. colesbury commented on Dec 3, 2025

    @colesbury
    colesbury
    on Dec 3, 2025
    Contributor
    More actions

    Here is the debug code that I'm using: https://gist.github.com/colesbury/639671ae1254a406ab72fa351e389a63

    It's messy and also causes occasional test failures itself, so I don't think it's worth commiting.

  17. colesbury
    added 2 commits that reference this issue on Dec 5, 2025

    [3.14] gh-140482: Avoid changing terminal settings in test_pty (gh-14…

    8fd39c0

    [3.13] gh-140482: Avoid changing terminal settings in test_pty (gh-14…

    b44cd56
  18. colesbury
    closed this as completedon Dec 5, 2025
  19. StanFromIreland
    added 2 commits that reference this issue on Dec 6, 2025

    pythongh-140482: Preserve and restore `stty echo` as a test environme…

    69973b7

    pythongh-140482: Avoid changing terminal settings in test_pty (python…

    44919d8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesOS-mactestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.