diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-10-02 08:19:28 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-10-02 08:21:54 -0400 |
commit | ab2ce66afa3d334933c5161fca74de433c0efdc4 (patch) | |
tree | 84b9f8ecf236bf2e4e3a6e9832c5b29a662a37ad | |
parent | 30adcab2456c1a8b0e48db5c4b5b4fe50f84ca69 (diff) | |
download | b4-ab2ce66afa3d334933c5161fca74de433c0efdc4.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.py | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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 |