msvcrt.getch() returns EOF sentinel as data when no console is attached
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
"msvcrt.getch() returns EOF sentinel as data when no console is attached" --body "## Summary
On Windows, `msvcrt.getch()` returns the CRT EOF sentinel as normal Python data when no console is attached, instead of raising `OSError`.
Reproducer
```powershell
PCbuild\amd64\python_d.exe -c "import ctypes, msvcrt, sys; ctypes.windll.kernel32.FreeConsole(); sys.exit(0 if msvcrt.getch() == b'\xff' else 1)"
echo $LASTEXITCODE \``
Actual result:
`$LASTEXITCODE` is `0`
This means `msvcrt.getch()` returned `b'\xff'` after `FreeConsole()`.
Expected behavior
If `_getch()` fails because no console is attached, the Python wrapper should raise `OSError` instead of returning `b'\xff'`.
Environment
- OS: Windows 11
- Build: CPython debug build
- Command used to build: `PCbuild\build.bat -c Debug`"
CPython versions tested on:
3.15
Operating systems tested on:
Windows
Linked PRs
- gh-149450
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
msvcrt.getch() のエントリポイントから開始し、FreeConsole() の後に PCbuild/amd64/python_d.exe コマンドを使って動作を再現してください。コンソールがない場合に b'\xff' が生成されず、代わりに OSError が発生することを確認してください。issue にはリンクされた PR gh-149450 が記載されているため、まずその作業を確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- operating-systems
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100