From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.3465.1603422105084138876 for ; Thu, 22 Oct 2020 20:01:45 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: mingyuex.liang@intel.com) IronPort-SDR: kuW9NrDKc9ESlRmaMshxekIiTJC/NIH5OTQZd9Cwmmr+1lfbuofKxnmovZ5qA9rJO7PRD/MwgI mHH4HpPLf8uA== X-IronPort-AV: E=McAfee;i="6000,8403,9782"; a="252320558" X-IronPort-AV: E=Sophos;i="5.77,404,1596524400"; d="scan'208";a="252320558" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2020 20:01:44 -0700 IronPort-SDR: kuKn9Oz2GKs0mtaLKb6Ofj7Y+8qT8vzEb8bY/ffwGsKQ9TRcw9IBgkPbelKzf/HtlTASXXwvnn NBOLctV6QCZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,404,1596524400"; d="scan'208";a="354304519" Received: from bob-desktop.ccr.corp.intel.com ([10.239.49.38]) by fmsmga002.fm.intel.com with ESMTP; 22 Oct 2020 20:01:43 -0700 From: mliang2x To: devel@edk2.groups.io Cc: Mingyue Liang , Bob Feng , Liming Gao , Yuwei Chen Subject: [PATCH] BaseTools: replace array.fromstring Method for supports py-2 and py-3. Date: Fri, 23 Oct 2020 11:01:42 +0800 Message-Id: <20201023030142.2015-1-mingyuex.liang@intel.com> X-Mailer: git-send-email 2.28.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Because after Python 3.2, array.fromstring method is renamed 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 --- BaseTools/Source/Python/Eot/EotMain.py | 8 ++++---- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/Python/Eot/EotMain.py b/BaseTools/Source/Python/Eot/EotMain.py index 791fcdfeae..2ff68054e6 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) + list(map(lambda str: DecData.fromlist([ord(str), 0]), TmpData)) except: TmpData = DeCompress('Framework', self[self._HEADER_SIZE_:]) DecData = array('B') - DecData.fromstring(TmpData) + list(map(lambda str: DecData.fromlist([ord(str), 0]), TmpData)) SectionList = [] Offset = 0 @@ -738,7 +738,7 @@ class GuidDefinedImage(Image): Offset = self.DataOffset - 4 TmpData = DeCompress('Framework', self[self.Offset:]) DecData = array('B') - DecData.fromstring(TmpData) + list(map(lambda str: DecData.fromlist([ord(str), 0]), TmpData)) 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) + list(map(lambda str: DecData.fromlist([ord(str), 0]), TmpData)) 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 dc1727c466..411af80c2b 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -463,7 +463,7 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip()) else: SectionData = array('B', [0, 0, 0, 0]) - SectionData.fromstring(Ui.encode("utf_16_le")) + list(map(lambda str: SectionData.fromlist([ord(str), 0]), Ui)) SectionData.append(0) SectionData.append(0) Len = len(SectionData) -- 2.28.0.windows.1