From: Segev Finer Date: Fri, 2 Jun 2017 16:26:01 +0000 (+0300) Subject: bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW... X-Git-Tag: v3.7.0a1~699 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=523776c3419f6795e78173d53c10e35ec4eed48d;p=thirdparty%2FPython%2Fcpython.git bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails (#1912) * bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails * bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails --- diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c index 814462f7c989..d51df7e8887c 100644 --- a/Modules/_io/winconsoleio.c +++ b/Modules/_io/winconsoleio.c @@ -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