Skip to content
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

Merged
merged 2 commits into from
Jun 2, 2017

Conversation

segevfiner
Copy link
Contributor

Found due to this: pytest-dev/py#103

@@ -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)
Copy link
Contributor

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)?

Copy link
Member

@zooba zooba left a 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.

@zooba zooba merged commit 523776c into python:master Jun 2, 2017
@zooba
Copy link
Member

zooba commented Jun 2, 2017

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
Copy link
Contributor Author

@zooba #1920 for the AppVeyor failure.

@zooba
Copy link
Member

zooba commented Jun 2, 2017

@segevfiner Merged that one too. Thanks!

zooba pushed a commit to zooba/cpython that referenced this pull request Jun 2, 2017
…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
zooba added a commit that referenced this pull request Jun 2, 2017
…iteConsoleW 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
@segevfiner segevfiner deleted the bpo-30544 branch June 2, 2017 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants