Skip to content

Commit 523776c

Browse files
segevfinerzooba
authored andcommitted
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
1 parent 7a82f9c commit 523776c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Modules/_io/winconsoleio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ _io__WindowsConsoleIO_write_impl(winconsoleio *self, Py_buffer *b)
10001000
wlen = MultiByteToWideChar(CP_UTF8, 0, b->buf, len, wbuf, wlen);
10011001
if (wlen) {
10021002
res = WriteConsoleW(self->handle, wbuf, wlen, &n, NULL);
1003-
if (n < wlen) {
1003+
if (res && n < wlen) {
10041004
/* Wrote fewer characters than expected, which means our
10051005
* len value may be wrong. So recalculate it from the
10061006
* characters that were written. As this could potentially

0 commit comments

Comments
 (0)