tee fix for pipelines

This commit is contained in:
Anthony Scopatz 2016-10-13 21:00:44 -04:00
parent 2428e445fc
commit 448c268758
2 changed files with 8 additions and 2 deletions

View file

@ -9,6 +9,8 @@
**Fixed:**
* Standard stream tees have been fixed to accept the possibility that
they may not be backed by a binary buffer.
they may not be backed by a binary buffer. This inludes the pipeline
stdout tee as well as the shell tees.
**Security:** None

View file

@ -1509,10 +1509,14 @@ class CommandPipeline:
err = env.get('XONSH_ENCODING_ERRORS')
lines = self.lines
stream = self.captured not in STDOUT_CAPTURE_KINDS
sydout_has_buffer = hasattr(sys.stdout, 'buffer')
for line in self.iterraw():
# write to stdout line ASAP, if needed
if stream:
sys.stdout.buffer.write(line)
if sydout_has_buffer:
sys.stdout.buffer.write(line)
else:
sys.stdout.write(line.decode(encoding=enc, errors=err))
sys.stdout.flush()
# do some munging of the line before we return it
line = RE_HIDDEN_BYTES.sub(b'', line)