[PATCH 08/10] Use bytes when dumping to stdout
Konstantin Ryabitsev <[email protected]> Fri, 2 Oct 2020 19:29:13 -0400
| Newsgroups | org.kernel.lore.signatures |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> Signed-off-by: Konstantin Ryabitsev <[email protected]> --- b4/mbox.py | 8 ++++---- 1 file 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 -- 2.26.2