-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails #1912
Conversation
…iteConsoleW fails
Modules/_io/winconsoleio.c
Outdated
@@ -1000,6 +1001,9 @@ _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 (!res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no point in calculating len
if the call failed, so why not instead add this to the following test, i.e. (res && n < wlen)
?
…iteConsoleW fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Ignore the AppVeyor failure - it is unrelated.
Forgot that I can just hit merge (different processes for me on different projects). Still needs a backport - I'll try to get to it today, but if someone else cherrypicks the change into 3.6 and submits as a PR, mention me and I'll merge. |
@segevfiner Merged that one too. Thanks! |
…iteConsoleW fails (python#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
Found due to this: pytest-dev/py#103