mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-06 17:30:59 +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."""
|
"""Streams lines to sys.stderr and the errors attribute."""
|
||||||
if not lines:
|
if not lines:
|
||||||
return
|
return
|
||||||
|
env = builtins.__xonsh_env__
|
||||||
|
enc = env.get('XONSH_ENCODING')
|
||||||
|
err = env.get('XONSH_ENCODING_ERRORS')
|
||||||
b = b''.join(lines)
|
b = b''.join(lines)
|
||||||
|
stderr_has_buffer = hasattr(sys.stderr, 'buffer')
|
||||||
# write bytes to std stream
|
# 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()
|
sys.stderr.flush()
|
||||||
# do some munging of the line before we save it to the attr
|
# do some munging of the line before we save it to the attr
|
||||||
b = RE_HIDDEN_BYTES.sub(b'', b)
|
b = RE_HIDDEN_BYTES.sub(b'', b)
|
||||||
|
|
Loading…
Add table
Reference in a new issue