Skip to content

Fix Windows terminal regressions across Py version#49

Open
jserv wants to merge 1 commit intomainfrom
fix-regression
Open

Fix Windows terminal regressions across Py version#49
jserv wants to merge 1 commit intomainfrom
fix-regression

Conversation

@jserv
Copy link
Contributor

@jserv jserv commented Mar 1, 2026

This restructures _flush() so flush always runs regardless of whether os.get_blocking succeeds. The old code coupled the get_blocking probe with the flush inside single try/except OSError when the probe failed (AttributeError on Python <3.12, OSError on 3.11 console handles), the flush was skipped and nothing reached the screen.

Each operation (fileno, get_blocking, set_blocking, flush, restore) is now isolated in its own try/except, with a finally block to guarantee blocking-state restoration.

It also sets DISABLE_NEWLINE_AUTO_RETURN (0x0008) alongside VT100 in _init_windows() to prevent auto-CR on LF causing cursor drift, with graceful fallback for pre-1607 builds.

Close #48


Summary by cubic

Fixes Windows terminal regressions across Python versions. Output now always flushes and cursor drift from LF on Windows consoles is prevented.

  • Bug Fixes
    • Made _flush() robust so it always runs, even if os.get_blocking is missing or raises OSError. Steps are isolated and the blocking state is restored.
    • On Windows, enable VT100 with DISABLE_NEWLINE_AUTO_RETURN (0x0008). Fallback to VT100-only on pre-1607 builds.
    • Menuconfig: only print run() result when present. CI: added Python/version checks, console probes, and _flush() robustness tests.

Written for commit a675570. Summary will update on new commits.

cubic-dev-ai[bot]

This comment was marked as resolved.

This restructures _flush() so flush always runs regardless of whether
os.get_blocking succeeds. The old code coupled the get_blocking probe
with the flush inside single try/except OSError when the probe failed
(AttributeError on Python <3.12, OSError on 3.11 console handles), the
flush was skipped and nothing reached the screen.

Each operation (fileno, get_blocking, set_blocking, flush, restore) is
now isolated in its own try/except, with a finally block to guarantee
blocking-state restoration.

It also sets DISABLE_NEWLINE_AUTO_RETURN (0x0008) alongside VT100 in
_init_windows() to prevent auto-CR on LF causing cursor drift, with
graceful fallback for pre-1607 builds.

Close #48
@jserv
Copy link
Contributor Author

jserv commented Mar 1, 2026

@eastWillow , Please test this pull request and determine if it works under Windows.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] Python Environment different version cause the UI regressions

1 participant