Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``WindowsConsoleIO``: Continue to read when interrupted by Ctrl+C if
``SIGINT`` is ignored or the handler doesn't raise an exception.
5 changes: 3 additions & 2 deletions Modules/_io/winconsoleio.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,14 +583,15 @@ read_console_w(HANDLE handle, DWORD maxlen, DWORD *readlen) {
break;
err = 0;
HANDLE hInterruptEvent = _PyOS_SigintEvent();
if (WaitForSingleObjectEx(hInterruptEvent, 100, FALSE)
== WAIT_OBJECT_0) {
DWORD state = WaitForSingleObjectEx(hInterruptEvent, 100, FALSE);
if (state == WAIT_OBJECT_0 || state == WAIT_TIMEOUT) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering every other possible result is a hard error (which we're currently ignoring... whoops), I don't think this is the right condition.

Probably in the WAIT_TIMEOUT case we want to just continue and not call PyErr_CheckSignals? We certainly shouldn't reset the event, because we haven't been given it

ResetEvent(hInterruptEvent);
Py_BLOCK_THREADS
sig = PyErr_CheckSignals();
Py_UNBLOCK_THREADS
if (sig < 0)
break;
continue;
}
}
*readlen += n;
Expand Down
5 changes: 3 additions & 2 deletions Parser/myreadline.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,16 @@ _PyOS_WindowsConsoleReadline(PyThreadState *tstate, HANDLE hStdIn)
goto exit;
err = 0;
HANDLE hInterruptEvent = _PyOS_SigintEvent();
if (WaitForSingleObjectEx(hInterruptEvent, 100, FALSE)
== WAIT_OBJECT_0) {
DWORD state = WaitForSingleObjectEx(hInterruptEvent, 100, FALSE);
if (state == WAIT_OBJECT_0 || state == WAIT_TIMEOUT) {
ResetEvent(hInterruptEvent);
PyEval_RestoreThread(tstate);
s = PyErr_CheckSignals();
PyEval_SaveThread();
if (s < 0) {
goto exit;
}
continue;
}
break;
}
Expand Down
Loading