[issue31966] print('hello\n', end='', flush=True) raises OSError when ran with py -u

2017-11-07 Thread Eryk Sun
Eryk Sun added the comment: The error is in _io__WindowsConsoleIO_write_impl. If it's passed a length 0 buffer, it still tries to decode it via MultiByteToWideChar, which fails as documented. As Serhiy says, it can simply return Python int(0) in the zero-length case.

[issue31966] print('hello\n', end='', flush=True) raises OSError when ran with py -u

2017-11-07 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I don't know which part of _WindowsConsoleIO.write() fails to handle empty bytes string, but the simplest and the most efficient way to fix this bug it to add an explicit check for zero length at the begin of this method and

[issue31966] print('hello\n', end='', flush=True) raises OSError when ran with py -u

2017-11-07 Thread STINNER Victor
STINNER Victor added the comment: serhiy.storchaka: "keywords: + easy (C)" For easy issue, you should explain how do you want the issue to be fixed. -- ___ Python tracker

[issue31966] print('hello\n', end='', flush=True) raises OSError when ran with py -u

2017-11-07 Thread STINNER Victor
STINNER Victor added the comment: Once the bug will be fixed, it would be nice to test this simple case :-) -- nosy: +haypo ___ Python tracker

[issue31966] print('hello\n', end='', flush=True) raises OSError when ran with py -u

2017-11-07 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +easy (C) stage: -> needs patch ___ Python tracker ___

[issue31966] print('hello\n', end='', flush=True) raises OSError when ran with py -u

2017-11-07 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The problem is with _WindowsConsoleIO. C:\py\cpython>python.bat -u -c "import sys; sys.stdout.buffer.write(b'')" Running Release|Win32 interpreter... Traceback (most recent call last): File "", line 1, in OSError: [WinError

[issue31966] print('hello\n', end='', flush=True) raises OSError when ran with py -u

2017-11-07 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- components: +IO nosy: +serhiy.storchaka ___ Python tracker ___

[issue31966] print('hello\n', end='', flush=True) raises OSError when ran with py -u

2017-11-07 Thread Guillaume Aldebert
New submission from Guillaume Aldebert : noticed on windows10, 3.6.3-64 and 3.7.0a2-64: using this test.py file: #!/usr/bin/env python3 print('hello\n', end='', flush=True) and running it in unbuffered mode: C:\Dev>py -u test.py hello Traceback (most recent call last):