]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW...
authorSegev Finer <segev208@gmail.com>
Fri, 2 Jun 2017 16:26:01 +0000 (19:26 +0300)
committerSteve Dower <steve.dower@microsoft.com>
Fri, 2 Jun 2017 16:26:01 +0000 (09:26 -0700)
* bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

* bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

Modules/_io/winconsoleio.c

index 814462f7c989f1c09685936645f2fb6b2e444be6..d51df7e8887cee595552bb168a897cf982e72dcc 100644 (file)
@@ -1000,7 +1000,7 @@ _io__WindowsConsoleIO_write_impl(winconsoleio *self, Py_buffer *b)
     wlen = MultiByteToWideChar(CP_UTF8, 0, b->buf, len, wbuf, wlen);
     if (wlen) {
         res = WriteConsoleW(self->handle, wbuf, wlen, &n, NULL);
-        if (n < wlen) {
+        if (res && n < wlen) {
             /* Wrote fewer characters than expected, which means our
              * len value may be wrong. So recalculate it from the
              * characters that were written. As this could potentially