summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorSegev Finer <segev208@gmail.com>2017-06-02 16:26:01 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2017-06-02 16:26:01 (GMT)
commit523776c3419f6795e78173d53c10e35ec4eed48d (patch)
treedd317e270fb71153bae5fc141d2a713c305eeb0d /Modules/_io
parent7a82f9c2b94d31c8f4cc8bb8e3151765d8b148d7 (diff)
downloadcpython-523776c3419f6795e78173d53c10e35ec4eed48d.zip
cpython-523776c3419f6795e78173d53c10e35ec4eed48d.tar.gz
cpython-523776c3419f6795e78173d53c10e35ec4eed48d.tar.bz2
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
Diffstat (limited to 'Modules/_io')
-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 814462f..d51df7e 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