msvcrt.getch() returns EOF sentinel as data when no console is attached
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dal punto di ingresso msvcrt.getch() e riproduci il comportamento con il comando PCbuild/amd64/python_d.exe dopo FreeConsole(). Conferma che l’assenza di una console non produca più b'\xff', ma sollevi invece OSError; l’issue elenca la PR collegata gh-149450, quindi esamina prima quel lavoro.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- operating-systems
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 35/100