summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2017-06-02 21:39:05 (GMT)
committerGitHub <noreply@github.com>2017-06-02 21:39:05 (GMT)
commitc63ae1122f84d4188ffadfd1454902093eb10be1 (patch)
tree66e865f62cca0e1c0fb1f98bad96a332bffd15e8 /Modules
parent1c92c0edca413c6f8ce8ec326a67451ae751ead9 (diff)
downloadcpython-c63ae1122f84d4188ffadfd1454902093eb10be1.zip
cpython-c63ae1122f84d4188ffadfd1454902093eb10be1.tar.gz
cpython-c63ae1122f84d4188ffadfd1454902093eb10be1.tar.bz2
bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails (#1912) (#1925)
* bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails * bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_io/winconsoleio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c
index 1d169e2..cbe2142 100644
--- a/Modules/_io/winconsoleio.c
+++ b/Modules/_io/winconsoleio.c
@@ -1017,7 +1017,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