mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-06 09:20:57 +01:00
fix AttributeError: 'TextTranscodingWrapper' object has no attribute 'buffer' on stderr
This commit is contained in:
parent
00ef1c4bfb
commit
17d419a8ac
1 changed files with 8 additions and 1 deletions
|
@ -1547,9 +1547,16 @@ class CommandPipeline:
|
|||
"""Streams lines to sys.stderr and the errors attribute."""
|
||||
if not lines:
|
||||
return
|
||||
env = builtins.__xonsh_env__
|
||||
enc = env.get('XONSH_ENCODING')
|
||||
err = env.get('XONSH_ENCODING_ERRORS')
|
||||
b = b''.join(lines)
|
||||
stderr_has_buffer = hasattr(sys.stderr, 'buffer')
|
||||
# write bytes to std stream
|
||||
sys.stderr.buffer.write(b)
|
||||
if stderr_has_buffer:
|
||||
sys.stderr.buffer.write(b)
|
||||
else:
|
||||
sys.stderr.write(b.decode(encoding=enc, errors=err))
|
||||
sys.stderr.flush()
|
||||
# do some munging of the line before we save it to the attr
|
||||
b = RE_HIDDEN_BYTES.sub(b'', b)
|
||||
|
|
Loading…
Add table
Reference in a new issue