Misbehavior of KeyboardInterrupt/EOFError and `input` on Windows
Aperta
Nessuno ha ancora preso questa issue.
OS-windows
pending
stdlib
type-bug
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Bug description:
import sys
from http.server import BaseHTTPRequestHandler, HTTPServer
from typing import NoReturn
def run_server() -> None:
httpd = HTTPServer(("", 0), BaseHTTPRequestHandler)
print("Starting service")
try:
httpd.serve_forever()
except KeyboardInterrupt:
print("Service stopped by ^C")
finally:
httpd.shutdown()
httpd.server_close()
def run() -> NoReturn:
print(f"Python: v{sys.version}")
while True:
try:
input("input>")
except KeyboardInterrupt:
print("^C")
continue
except EOFError:
print("Manually force exit")
sys.exit()
run_server()
if __name__ == "__main__":
run()
I'm not sure if it's a bug
Expected
- When
input,^Ccan cancel current input and enter the next cycle - When
server,^Ccan close server and enter the next cycle ^Zto exit (print("Manually force exit"))
Factual
Enterto open server -> type^Cto close server -> type^C- When
py xxx.py,print("Manually force exit") - When
pdb,\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_sys_monitoring\_pydevd_sys_monitoring.py", line 873 KeyboardInterrupt
- When
CPython versions tested on:
3.14
Operating systems tested on:
Windows
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 riproducendo l'esempio run() fornito su Windows con Python 3.14, concentrandoti su input, KeyboardInterrupt, EOFError e sulla transizione di run_server. Confronta il comportamento quando viene avviato normalmente e sotto pdb; il lavoro è completato quando il flusso di controllo osservato corrisponde alle aspettative indicate per l'annullamento dell'input, l'arresto del server e l'uscita con ^Z.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- cli, operating-systems
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100