From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EA50z44Y; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575495516; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YqGT7ERJc1nKknsLPccnTzXQKRjXaTn8UYCBuzZVSZs=; b=EA50z44Y6P/rTjk1+2uU4hGVnQi05Mmxn0mk1TuEatNUXda7qFYPIx2I/gC4rXs/AToxVZ oF32R7D/WYB4rI7whtJjWkEfucy8kCS7JyF15lWI1IiKyoMHQF8vkV5XwcPSjRPksxONBh bxZjVhBY4gUTo7gRq54wkSbAqjvUAAQ= 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 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) 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: [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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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