Skip to content

Commit c63ae11

Browse files
authored
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
1 parent 1c92c0e commit c63ae11

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
@@ -1017,7 +1017,7 @@ _io__WindowsConsoleIO_write_impl(winconsoleio *self, Py_buffer *b)
10171017
wlen = MultiByteToWideChar(CP_UTF8, 0, b->buf, len, wbuf, wlen);
10181018
if (wlen) {
10191019
res = WriteConsoleW(self->handle, wbuf, wlen, &n, NULL);
1020-
if (n < wlen) {
1020+
if (res && n < wlen) {
10211021
/* Wrote fewer characters than expected, which means our
10221022
* len value may be wrong. So recalculate it from the
10231023
* characters that were written. As this could potentially

0 commit comments

Comments
 (0)