Blame 0002-BaseTools-Work-around-array.array.tostring-removal-i.patch

a6540d
From f6e649b25150c1417ebcd595004da6d788d7c9c5 Mon Sep 17 00:00:00 2001
a6540d
Message-Id: <f6e649b25150c1417ebcd595004da6d788d7c9c5.1596577611.git.crobinso@redhat.com>
a6540d
In-Reply-To: <a32df3463befa04913fd1934ed264038a9eae00f.1596577611.git.crobinso@redhat.com>
a6540d
References: <a32df3463befa04913fd1934ed264038a9eae00f.1596577611.git.crobinso@redhat.com>
a6540d
From: Cole Robinson <crobinso@redhat.com>
a6540d
Date: Tue, 4 Aug 2020 17:24:32 -0400
a6540d
Subject: [PATCH 2/2] BaseTools: Work around array.array.tostring() removal in
a6540d
 python 3.9
a6540d
a6540d
In python3, array.array.tostring() was a compat alias for tobytes().
a6540d
tostring() was removed in python 3.9.
a6540d
a6540d
Convert this to use tolist() which should be valid for all python
a6540d
versions.
a6540d
a6540d
This fixes this build error on python3.9:
a6540d
a6540d
(Python 3.9.0b5 on linux) Traceback (most recent call last):
a6540d
  File "/root/edk2/edk2-edk2-stable202002/BaseTools/BinWrappers/PosixLike/../../Source/Python/Trim/Trim.py", line 593, in Main
a6540d
    GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.DebugDir, CommandOptions.OutputFile)
a6540d
  File "/root/edk2/edk2-edk2-stable202002/BaseTools/BinWrappers/PosixLike/../../Source/Python/Trim/Trim.py", line 449, in GenerateVfrBinSec
a6540d
    VfrUniOffsetList = GetVariableOffset(MapFileName, EfiFileName, VfrNameList)
a6540d
  File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Misc.py", line 88, in GetVariableOffset
a6540d
    return _parseForGCC(lines, efifilepath, varnames)
a6540d
  File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Misc.py", line 151, in _parseForGCC
a6540d
    efisecs = PeImageClass(efifilepath).SectionHeaderList
a6540d
  File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Misc.py", line 1638, in __init__
a6540d
    if ByteArray.tostring() != b'PE\0\0':
a6540d
AttributeError: 'array.array' object has no attribute 'tostring'
a6540d
a6540d
Signed-off-by: Cole Robinson <crobinso@redhat.com>
a6540d
---
a6540d
 BaseTools/Source/Python/Common/Misc.py | 2 +-
a6540d
 1 file changed, 1 insertion(+), 1 deletion(-)
a6540d
a6540d
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
a6540d
index da5fb380f0..751b2c24f0 100755
a6540d
--- a/BaseTools/Source/Python/Common/Misc.py
a6540d
+++ b/BaseTools/Source/Python/Common/Misc.py
a6540d
@@ -1635,7 +1635,7 @@ class PeImageClass():
a6540d
         ByteArray = array.array('B')
a6540d
         ByteArray.fromfile(PeObject, 4)
a6540d
         # PE signature should be 'PE\0\0'
a6540d
-        if ByteArray.tostring() != b'PE\0\0':
a6540d
+        if ByteArray.tolist() != [ord('P'), ord('E'), 0, 0]:
a6540d
             self.ErrorInfo = self.FileName + ' has no valid PE signature PE00'
a6540d
             return
a6540d
 
a6540d
-- 
a6540d
2.26.2
a6540d