diff options
author | ValeriyaSinevich <valeriya.sinevich@phystech.edu> | 2018-07-19 22:34:03 (GMT) |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2018-07-19 22:34:03 (GMT) |
commit | ce75df3031c86b78311b1ad76c39c0b39d7d7424 (patch) | |
tree | f1bd2a5e30885b6f45c0df239d6063e30aa2eb9c /Modules/_io | |
parent | 81950495ba2c36056e0ce48fd37d514816c26747 (diff) | |
download | cpython-ce75df3031c86b78311b1ad76c39c0b39d7d7424.zip cpython-ce75df3031c86b78311b1ad76c39c0b39d7d7424.tar.gz cpython-ce75df3031c86b78311b1ad76c39c0b39d7d7424.tar.bz2 |
bpo-30237: Output error when ReadConsole is canceled by CancelSynchronousIo. (GH-7911)
Diffstat (limited to 'Modules/_io')
-rw-r--r-- | Modules/_io/winconsoleio.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c index 2bf48eb..f084066 100644 --- a/Modules/_io/winconsoleio.c +++ b/Modules/_io/winconsoleio.c @@ -556,7 +556,8 @@ read_console_w(HANDLE handle, DWORD maxlen, DWORD *readlen) { Py_BEGIN_ALLOW_THREADS DWORD off = 0; while (off < maxlen) { - DWORD n, len = min(maxlen - off, BUFSIZ); + DWORD n = (DWORD)-1; + DWORD len = min(maxlen - off, BUFSIZ); SetLastError(0); BOOL res = ReadConsoleW(handle, &buf[off], len, &n, NULL); @@ -564,6 +565,9 @@ read_console_w(HANDLE handle, DWORD maxlen, DWORD *readlen) { err = GetLastError(); break; } + if (n == (DWORD)-1 && (err = GetLastError()) == ERROR_OPERATION_ABORTED) { + break; + } if (n == 0) { err = GetLastError(); if (err != ERROR_OPERATION_ABORTED) |