Skip to content

Commit

Permalink
A TextIOWrapper that wraps _winconsole._WindowsConsoleWriter expects …
Browse files Browse the repository at this point in the history
…a buffered stream.

TextIOWrapper expects a *buffered* stream not an unbuffered one. It wont
check how much data was written and will drop data if you don't write it
all.

This reproduces quite well on Python 3.6. Likely due to changes in
TextIOWrapper.

Fixes: #816
  • Loading branch information
segevfiner committed Jul 9, 2017
1 parent ebcbef9 commit 6417e35
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions click/_winconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ def _get_text_stdin(buffer_stream):

def _get_text_stdout(buffer_stream):
text_stream = _NonClosingTextIOWrapper(
_WindowsConsoleWriter(STDOUT_HANDLE),
io.BufferedWriter(_WindowsConsoleWriter(STDOUT_HANDLE)),
'utf-16-le', 'strict', line_buffering=True)
return ConsoleStream(text_stream, buffer_stream)


def _get_text_stderr(buffer_stream):
text_stream = _NonClosingTextIOWrapper(
_WindowsConsoleWriter(STDERR_HANDLE),
io.BufferedWriter(_WindowsConsoleWriter(STDERR_HANDLE)),
'utf-16-le', 'strict', line_buffering=True)
return ConsoleStream(text_stream, buffer_stream)

Expand Down

0 comments on commit 6417e35

Please sign in to comment.