aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-10-02 08:19:28 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-10-02 08:19:28 -0400
commit2368a6a3fd32be60ecc9ae2d45e0f608c5b77545 (patch)
treed2140d879ce393efcd8a5bca209ad01ab2ed1afa
parentc02e406e25c20ceacfd1937f6e63099fd471ff14 (diff)
downloadb4-2368a6a3fd32be60ecc9ae2d45e0f608c5b77545.tar.gz
Use bytes when dumping to stdout
We don't need to needlessly convert to unicode when dumping to stdout, especially when it can lead to crashers when we encounter other charsets. Reported-by: Rob Herring <robh@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/mbox.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/b4/mbox.py b/b4/mbox.py
index fb82389..754d0f8 100644
--- a/b4/mbox.py
+++ b/b4/mbox.py
@@ -234,8 +234,8 @@ def mbox_to_am(mboxfile, cmdargs):
am_mbx.close()
if cmdargs.outdir == '-':
logger.info('---')
- with open(am_filename, 'r') as fh:
- shutil.copyfileobj(fh, sys.stdout)
+ with open(am_filename, 'rb') as fh:
+ shutil.copyfileobj(fh, sys.stdout.buffer)
os.unlink(am_filename)
thanks_record_am(lser, cherrypick=cherrypick)
@@ -511,8 +511,8 @@ def main(cmdargs):
mbx.close()
if cmdargs.outdir == '-':
logger.info('---')
- with open(threadmbox, 'r') as fh:
- shutil.copyfileobj(fh, sys.stdout)
+ with open(threadmbox, 'rb') as fh:
+ shutil.copyfileobj(fh, sys.stdout.buffer)
os.unlink(threadmbox)
return