Open
Conversation
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
Contributor
Author
|
@eastWillow , Please test this pull request and determine if it works under Windows. |
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.
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.
Written for commit a675570. Summary will update on new commits.