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.web10.308.1597167128927113654 for ; Tue, 11 Aug 2020 10:32:09 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=axel17Mc; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: crobinso@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597167128; 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: in-reply-to:in-reply-to:references:references; bh=sZRNGVqwGyFRSNys7LRd4yF4Jwm8BnNLj+t6lvZ3rYA=; b=axel17Mc+rikNzJgyKoOvMck51Xv0c9nSnzhSLIDc5LVs5wKsH5JbpNJlRHui/2gyXO2F7 TCoGl/AoodAsfNocPEJr2uXye152WTl3wzyBgxZHOVTMTN1xUaEMGAbM/KbjcQXoM+UkSF mJNbJgKXJQN+yBCnODdjDTRE45nXDwY= 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-306-iTQ_lReGOUaohxosiqIIng-1; Tue, 11 Aug 2020 13:32:06 -0400 X-MC-Unique: iTQ_lReGOUaohxosiqIIng-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49B0F8015F0; Tue, 11 Aug 2020 17:32:05 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-118-49.rdu2.redhat.com [10.10.118.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id B85351001281; Tue, 11 Aug 2020 17:32:04 +0000 (UTC) From: "Cole" To: devel@edk2.groups.io Cc: bob.c.feng@intel.com, liming.gao@intel.com, Cole Robinson Subject: [PATCH 2/2] BaseTools: Work around array.array.tostring() removal in python 3.9 Date: Tue, 11 Aug 2020 13:28:18 -0400 Message-Id: <95d3490d62f9d320e61efa10cba7424a6f626f66.1597166808.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=crobinso@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable In python3, array.array.tostring() was a compat alias for tobytes(). tostring() was removed in python 3.9. Convert this to use tolist() which should be valid for all python versions. This fixes this build error on python3.9: (Python 3.9.0b5 on linux) Traceback (most recent call last): File "/root/edk2/edk2-edk2-stable202002/BaseTools/BinWrappers/PosixLike/.= ./../Source/Python/Trim/Trim.py", line 593, in Main GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.DebugDir, C= ommandOptions.OutputFile) File "/root/edk2/edk2-edk2-stable202002/BaseTools/BinWrappers/PosixLike/.= ./../Source/Python/Trim/Trim.py", line 449, in GenerateVfrBinSec VfrUniOffsetList =3D GetVariableOffset(MapFileName, EfiFileName, VfrNam= eList) File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Mi= sc.py", line 88, in GetVariableOffset return _parseForGCC(lines, efifilepath, varnames) File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Mi= sc.py", line 151, in _parseForGCC efisecs =3D PeImageClass(efifilepath).SectionHeaderList File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Mi= sc.py", line 1638, in __init__ if ByteArray.tostring() !=3D b'PE\0\0': AttributeError: 'array.array' object has no attribute 'tostring' Signed-off-by: Cole Robinson --- BaseTools/Source/Python/Common/Misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index ad55671080..4be7957138 100755 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1635,7 +1635,7 @@ class PeImageClass(): ByteArray =3D array.array('B')=0D ByteArray.fromfile(PeObject, 4)=0D # PE signature should be 'PE\0\0'=0D - if ByteArray.tostring() !=3D b'PE\0\0':=0D + if ByteArray.tolist() !=3D [ord('P'), ord('E'), 0, 0]:=0D self.ErrorInfo =3D self.FileName + ' has no valid PE signature= PE00'=0D return=0D =20=0D --=20 2.26.2