bpo-30237: Output error when ReadConsole is canceled by CancelSynchronousIo. (GH-7911)

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 @@
     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 @@
             err = GetLastError();
             break;
         }
+        if (n == (DWORD)-1 && (err = GetLastError()) == ERROR_OPERATION_ABORTED) {
+            break;
+        }
         if (n == 0) {
             err = GetLastError();
             if (err != ERROR_OPERATION_ABORTED)