From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web12.7646.1604900893989210282 for ; Sun, 08 Nov 2020 21:48:14 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: mingyuex.liang@intel.com) IronPort-SDR: Lqc/ERrsI9NAsR+V4FOWeh6ou7VbBoMansZLJe2mTjx59GlohQFi/s07hGsGz94dCFRWDv7cem 6erimEiDlVCQ== X-IronPort-AV: E=McAfee;i="6000,8403,9799"; a="169905886" X-IronPort-AV: E=Sophos;i="5.77,462,1596524400"; d="scan'208";a="169905886" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2020 21:48:12 -0800 IronPort-SDR: x2E3xrVoWbqfF3rz4RonH8cijVLVUwNuIydAuwjwdwaOTAGf1LZhx0K/vjWlhfDIUcgD9B5f8k 5rurkKV9vAYg== X-IronPort-AV: E=Sophos;i="5.77,462,1596524400"; d="scan'208";a="540698527" Received: from bob-desktop.ccr.corp.intel.com ([10.239.49.41]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2020 21:48:11 -0800 From: "Mingyue Liang" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Yuwei Chen Subject: [PATCH 1/1] BaseTools: replace fromstring and tostring Method. Date: Mon, 9 Nov 2020 13:48:06 +0800 Message-Id: <20201109054806.1979-1-mingyuex.liang@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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..a2f18b5aff25 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(list(TmpData.encode('utf_16_le'))) except: TmpData = DeCompress('Framework', self[self._HEADER_SIZE_:]) DecData = array('B') - DecData.fromstring(TmpData) + DecData.fromlist(list(TmpData.encode('utf_16_le'))) 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(list(TmpData.encode('utf_16_le'))) 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(list(TmpData.encode('utf_16_le'))) 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..a1b5be3cf385 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(list(Ui.encode('utf_16_le'))) 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.28.0.windows.1