From nobody Mon May 20 02:35:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+51758+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+51758+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1575495518; cv=none; d=zohomail.com; s=zohoarc; b=J5leYdbYjqRna7s3UOjqaj4lZlv7hxv577b4JiYRmDzz9RANcgcSmt4hDy9acwPwdGoABjhecvxphXqxEHGWArJkVULtuMevgtdCTw4DNrKzVxBWqNqtt5HnIyHmj6uFnOCoz9lCQ0RuMdvICcHxQiBbkeOLXg1SlEqfUlvfF3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575495518; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=6Bu7OlP6JLW831ATiPGxRA0MrpUZK/UP9zjkHoLJPOQ=; b=NopBnOSN4kEPUXxypUHTkGP8jIMyKbU/+bNQqbOihfp/err90O+ricH0M8p07p3oHbG16tWMx9cRENbmvGl5QigasvlKQTd9UDwoPAm5hEgXz1JYPHpT/4atnHRL2IUlCC81x5+QUMuVAcEYfGwpjZ/oBTnaMjcDknYDzCKGISQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+51758+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1575495518039167.91987682622926; Wed, 4 Dec 2019 13:38:38 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id lKCJYY1788612xUDxBAmmi6U; Wed, 04 Dec 2019 13:38:37 -0800 X-Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web12.3416.1575495516927329505 for ; Wed, 04 Dec 2019 13:38:37 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-Q1xU3irbPdioJCrkflsecA-1; Wed, 04 Dec 2019 16:38:34 -0500 X-Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3A6B41005502; Wed, 4 Dec 2019 21:38:33 +0000 (UTC) X-Received: from x1w.redhat.com (ovpn-205-76.brq.redhat.com [10.40.205.76]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4D36B19C69; Wed, 4 Dec 2019 21:38:27 +0000 (UTC) From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= To: devel@edk2.groups.io Cc: Zhiju Fan , Philippe Mathieu-Daude , Bob Feng , Liming Gao Subject: [edk2-devel] [RFC PATCH] BaseTools: Fix Python3 encoding issue in TestTools Date: Wed, 4 Dec 2019 22:38:25 +0100 Message-Id: <20191204213825.27644-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: Q1xU3irbPdioJCrkflsecA-1 X-Mimecast-Spam-Score: 0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,philmd@redhat.com X-Gm-Message-State: E2KHQKf02rbWJcAxh1VRyr9jx1787277AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1575495517; bh=Nm2nluOkrlYUz009RLP0fUpnU7HxfMuZsBTASzlKS+0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=AhmMwIzfR54gxnCnUFlQsiNEM3If+D2E/m8Oh3ltEnKideOeCOKYD+6k9OSxkeSToNI KFpJLSngbuoB5/IujtkP/x5QK4KS9LAJW/ayepl0kuo3IV6S+t+AjCAMAaK0T3y/N8Qi1 tWvmSNH1BxDShJDxqdmadXixbw0AM/3P5Qc= X-ZohoMail-DKIM: pass (identity @groups.io) Under Centos 7.7 we get: Build environment: Linux-3.10.0-1062.7.1.el7.x86_64-x86_64-with-centos-7.= 7.1908-Core [...] =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ERROR: testRandomDataCycles (TianoCompress.Tests) ---------------------------------------------------------------------- Traceback (most recent call last): File "edk2/BaseTools/Tests/TianoCompress.py", line 60, in testRandomDat= aCycles self.compressionTestCycle(data) File "edk2/BaseTools/Tests/TianoCompress.py", line 46, in compressionTe= stCycle start =3D self.ReadTmpFile('input') File "edk2/BaseTools/Tests/TestTools.py", line 139, in ReadTmpFile data =3D f.read() File "/usr/lib64/python3.6/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: o= rdinal not in range(128) ---------------------------------------------------------------------- Fix by specifying the UTF-8 encoding. Cc: Bob Feng Cc: Liming Gao Signed-off-by: Philippe Mathieu-Daude --- RFC because I'm not sure this is the best way to fix this, but this is similar to commit 31e3eeb5e3d2d. --- BaseTools/Tests/TestTools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Tests/TestTools.py b/BaseTools/Tests/TestTools.py index 1099fd4eeaea..41cdb28b0c8c 100644 --- a/BaseTools/Tests/TestTools.py +++ b/BaseTools/Tests/TestTools.py @@ -135,7 +135,7 @@ class BaseToolsTest(unittest.TestCase): return open(os.path.join(self.testDir, fileName), mode) =20 def ReadTmpFile(self, fileName): - f =3D open(self.GetTmpFilePath(fileName), 'r') + f =3D codecs.open(self.GetTmpFilePath(fileName), 'r', encoding=3D'= utf-8') data =3D f.read() f.close() return data --=20 2.21.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#51758): https://edk2.groups.io/g/devel/message/51758 Mute This Topic: https://groups.io/mt/66540766/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-