From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web12.7365.1610021257742255541 for ; Thu, 07 Jan 2021 04:07:42 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dKsS/B2z; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610021256; 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=NYYoTUcweIEoMdq94AH4gaX3ZsFpMeLyaHloHHsaiM0=; b=dKsS/B2zp8u6jZ0/SExRUN9JG7qIEJWkK5dEP7Dch/UfbZZYg4agJ9IRs2TnueqRnyNv+9 qoDGpUSVg8VbboAq1zF9FZRsiHwfVII9eR5h+MbT6YdA+dyQcoTI665Se7aw+35o9PEp1s IJbewIPEUvPm8qW2O5KFl4VyMr0LiM8= 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-465-jrDsqCzLNdqtkc67BsCxKA-1; Thu, 07 Jan 2021 07:07:34 -0500 X-MC-Unique: jrDsqCzLNdqtkc67BsCxKA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB3FB107ACE8; Thu, 7 Jan 2021 12:07:32 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-119.ams2.redhat.com [10.36.114.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 241A360BF1; Thu, 7 Jan 2021 12:07:30 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 1/1] BaseTools: replace fromstring and tostring Method. To: devel@edk2.groups.io, bob.c.feng@intel.com, "Liang, MingyueX" Cc: Liming Gao , "Chen, Christine" References: <20201113060406.379-1-mingyuex.liang@intel.com> From: "Laszlo Ersek" Message-ID: Date: Thu, 7 Jan 2021 13:07:30 +0100 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 12/22/20 03:06, Bob Feng wrote: > Reviewed-by: Bob Feng Has this patch been merged? Thanks Laszlo > -----Original Message----- > From: Mingyue Liang > Sent: Friday, November 13, 2020 2:04 PM > To: devel@edk2.groups.io > Cc: Feng, Bob C ; Liming Gao ; Chen, Christine > Subject: [PATCH 1/1] BaseTools: replace fromstring and tostring Method. > > Because after Python 3.2, array.tostring and array.fromstring method is renamed tobytes and frombytes,so it needs to be modified to support python2 and python3 methods. > > Signed-off-by: Mingyue Liang > Cc: Bob Feng > Cc: Liming Gao > Cc: Yuwei Chen > Cc: Mingyue Liang > --- > BaseTools/Source/Python/Eot/EotMain.py | 10 +++++----- > BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 4 ++-- > 2 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/BaseTools/Source/Python/Eot/EotMain.py b/BaseTools/Source/Python/Eot/EotMain.py > index 791fcdfeaed8..68cc9f1239f5 100644 > --- a/BaseTools/Source/Python/Eot/EotMain.py > +++ b/BaseTools/Source/Python/Eot/EotMain.py > @@ -152,11 +152,11 @@ class CompressedImage(Image): > try: > TmpData = DeCompress('Efi', self[self._HEADER_SIZE_:]) > DecData = array('B') > - DecData.fromstring(TmpData) > + DecData.fromlist(array('B',TmpData).tolist()) > except: > TmpData = DeCompress('Framework', self[self._HEADER_SIZE_:]) > DecData = array('B') > - DecData.fromstring(TmpData) > + DecData.fromlist(array('B',TmpData).tolist()) > > SectionList = [] > Offset = 0 > @@ -196,7 +196,7 @@ class Ui(Image): > return len(self) > > def _GetUiString(self): > - return codecs.utf_16_decode(self[0:-2].tostring())[0] > + return codecs.utf_16_decode(b"".join(list(map(lambda > + x:bytes([x]), self[0:-2].tolist()))))[0] > > String = property(_GetUiString) > > @@ -738,7 +738,7 @@ class GuidDefinedImage(Image): > Offset = self.DataOffset - 4 > TmpData = DeCompress('Framework', self[self.Offset:]) > DecData = array('B') > - DecData.fromstring(TmpData) > + DecData.fromlist(array('B',TmpData).tolist()) > Offset = 0 > while Offset < len(DecData): > Sec = Section() > @@ -759,7 +759,7 @@ class GuidDefinedImage(Image): > > TmpData = DeCompress('Lzma', self[self.Offset:]) > DecData = array('B') > - DecData.fromstring(TmpData) > + DecData.fromlist(array('B',TmpData).tolist()) > Offset = 0 > while Offset < len(DecData): > Sec = Section() > diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py > index dc1727c4666d..83fa48187996 100644 > --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py > +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py > @@ -463,12 +463,12 @@ class GenFdsGlobalVariable: > GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip()) > else: > SectionData = array('B', [0, 0, 0, 0]) > - SectionData.fromstring(Ui.encode("utf_16_le")) > + > + SectionData.fromlist(array('B',Ui.encode('utf-16-le')).tolist()) > SectionData.append(0) > SectionData.append(0) > Len = len(SectionData) > GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15) > - SaveFileOnChange(Output, SectionData.tostring()) > + SaveFileOnChange(Output, b"".join(list(map(lambda > + x:bytes([x]), SectionData.tolist())))) > > elif Ver: > Cmd += ("-n", Ver) > -- > 2.29.2.windows.2 > > > > > >