Skip to content

Reset a raw Windows console before py-doc new and init ask anything - #136

Merged
markbac merged 1 commit into
mainfrom
claude/gracious-ride-1x1cpi
Oct 16, 2026
Merged

markbac merged 1 commit into
mainfrom
claude/gracious-ride-1x1cpi

Conversation

@markbac

@markbac markbac commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Summary

On Windows, py-doc new stopped 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, which py-doc build drives, 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 through GetConsoleMode/SetConsoleMode. Off Windows, or when standard input is not a console, it does nothing.
  • py-doc new and py-doc init call it before their first question, only when they will ask.
  • Troubleshooting in the reference describes the symptom, and what to do in an older version (close the tab, or answer with options and -y).

Testing

  • tests/test_platform.py: no effect off Windows; with a stand-in kernel32 reporting a raw mode (0x0200), the mode is set back with processed input, line input and echo.
  • Not run on a real Windows console in this environment: please check py-doc new after a py-doc build in the same tab.
  • Full suite passes except the 7 tests/test_examples.py failures that also occur on main here (no Graphviz, Mermaid or PlantUML); ruff check and py-doc lint docs/guide --strict are clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ket2UPXgz46XKSUqpuPixk


Generated by Claude Code

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
@markbac
markbac merged commit e26981a into main Oct 16, 2026
6 checks passed
@markbac
markbac deleted the claude/gracious-ride-1x1cpi branch October 19, 2026 08:53
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.

2 participants