Repository navigation
Reset a raw Windows console before py-doc new and init ask anything - #136
Merged
Merged
Conversation
A program run earlier in the same console, such as wsl.exe during a build, can leave the console input raw: no line input, no echo, Ctrl+C read as a key. input() then never returns, and the user cannot answer or stop the wizard. restore_console_input turns line input, echo and Ctrl+C back on (Windows only) before the first question. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ket2UPXgz46XKSUqpuPixk
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.
Summary
On Windows,
py-doc newstopped at its first question: nothing typed was shown, and Enter and Ctrl+C did nothing. The process could not be stopped from the keyboard.A program run earlier in the same console can leave its input raw: no line input, no echo, Ctrl+C read as a key.
wsl.exe, whichpy-doc builddrives, is the likely one. PowerShell's line editor fixes the mode only while you type a command, and hands the raw mode on to the next program.input()then waits for a line ending that never arrives.platform.restore_console_input()turns line input, echo and Ctrl+C processing back on throughGetConsoleMode/SetConsoleMode. Off Windows, or when standard input is not a console, it does nothing.py-doc newandpy-doc initcall it before their first question, only when they will ask.-y).Testing
tests/test_platform.py: no effect off Windows; with a stand-inkernel32reporting a raw mode (0x0200), the mode is set back with processed input, line input and echo.py-doc newafter apy-doc buildin the same tab.tests/test_examples.pyfailures that also occur onmainhere (no Graphviz, Mermaid or PlantUML);ruff checkandpy-doc lint docs/guide --strictare clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01Ket2UPXgz46XKSUqpuPixk
Generated by Claude Code