Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A10FBC35257 for ; Fri, 2 Oct 2020 23:29:49 +0000 (UTC) Received: by mail.kernel.org (Postfix) id 859AB2074B; Fri, 2 Oct 2020 23:29:49 +0000 (UTC) Received: from [192.168.1.64] (unknown [89.36.78.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4B6AE2072E for ; Fri, 2 Oct 2020 23:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601681389; bh=XkJfvEawfiy11cM2jNzsaRKfteVtE5wK71RDBCqPLbY=; h=From:List-Id:To:Subject:Date:In-Reply-To:References:From; b=HQJfxOgohY1WzaVCOpkTMtBCQeeo6hepIKij/SicE83Eh+84WnhUDmHT28XeCQ7re Xm0hlYwNxeDpRucj+ItYwN55Nhcdfh++qmzqlql0G4JbviBMh3ZeWcEBF7q6+aVMwA hx11HyBDphOOSlS0JfkTx5w5asXWjDAJnJTLQ0fQ= From: Konstantin Ryabitsev List-Id: To: signatures@kernel.org Subject: [PATCH 08/10] Use bytes when dumping to stdout Date: Fri, 2 Oct 2020 19:29:13 -0400 Message-Id: <20201002232915.1728301-9-konstantin@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201002232915.1728301-1-konstantin@linuxfoundation.org> References: <20201002232915.1728301-1-konstantin@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patch-Hashes: v=1; h=sha256; g=322228a4cce67cb77bf94334b8e41c1f70339563; i=mt/G/GNNelFhMa8lonCsF4m9se8UQJnzprhJ7pHyJoE=; m=QnmSgD8oMX1bXJf2BgjGMQmM9RY1c6fC0Nfvnxtab9o=; p=1A432K2kmlNwh6yy2gnpTdbnudPZkgzID2yt9tIQE0o= X-Patch-Sig: m=pgp; i=konstantin@linuxfoundation.org; s=0xB6C41CE35664996C; b=iHUEABYIAB0WIQR2vl2yUnHhSB5njDW2xBzjVmSZbAUCX3e36QAKCRC2xBzjVmSZbIKcAQCBzQe JTGzt3jqDzGAZfEl7tBY0SXRwuX0qQD36be1y6gD/Ql/rTl4LLs4eZiRXoTW/amGNJlYUlJIwRajz X3RBPQI= 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 Signed-off-by: Konstantin Ryabitsev --- 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