Reviewed-by: Yuwei Chen<yuwei.c...@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Cole
> Sent: Wednesday, August 12, 2020 1:28 AM
> To: devel@edk2.groups.io
> Cc: Feng, Bob C <bob.c.f...@intel.com>; Gao, Liming
> <liming....@intel.com>; Cole Robinson <crobi...@redhat.com>
> Subject: [edk2-devel] [PATCH 2/2] BaseTools: Work around
> array.array.tostring() removal in python 3.9
> 
> 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/Tr
> im.py", line 593, in Main
>     GenerateVfrBinSec(CommandOptions.ModuleName,
> CommandOptions.DebugDir, CommandOptions.OutputFile)
>   File "/root/edk2/edk2-edk2-
> stable202002/BaseTools/BinWrappers/PosixLike/../../Source/Python/Trim/Tr
> im.py", line 449, in GenerateVfrBinSec
>     VfrUniOffsetList = GetVariableOffset(MapFileName, EfiFileName,
> VfrNameList)
>   File "/root/edk2/edk2-edk2-
> stable202002/BaseTools/Source/Python/Common/Misc.py", line 88, in
> GetVariableOffset
>     return _parseForGCC(lines, efifilepath, varnames)
>   File "/root/edk2/edk2-edk2-
> stable202002/BaseTools/Source/Python/Common/Misc.py", line 151, in
> _parseForGCC
>     efisecs = PeImageClass(efifilepath).SectionHeaderList
>   File "/root/edk2/edk2-edk2-
> stable202002/BaseTools/Source/Python/Common/Misc.py", line 1638, in
> __init__
>     if ByteArray.tostring() != b'PE\0\0':
> AttributeError: 'array.array' object has no attribute 'tostring'
> 
> Signed-off-by: Cole Robinson <crobi...@redhat.com>
> ---
>  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/Python/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 = array.array('B')
>          ByteArray.fromfile(PeObject, 4)
>          # PE signature should be 'PE\0\0'
> -        if ByteArray.tostring() != b'PE\0\0':
> +        if ByteArray.tolist() != [ord('P'), ord('E'), 0, 0]:
>              self.ErrorInfo = self.FileName + ' has no valid PE signature 
> PE00'
>              return
> 
> --
> 2.26.2
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#64132): https://edk2.groups.io/g/devel/message/64132
Mute This Topic: https://groups.io/mt/76131663/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to