public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yuwei Chen" <yuwei.chen@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"crobinso@redhat.com" <crobinso@redhat.com>
Cc: "Feng, Bob C" <bob.c.feng@intel.com>,
	"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [edk2-devel] [PATCH 2/2] BaseTools: Work around array.array.tostring() removal in python 3.9
Date: Thu, 13 Aug 2020 00:16:40 +0000	[thread overview]
Message-ID: <DM5PR11MB1594FAB1F844EAF288C5BD2D96430@DM5PR11MB1594.namprd11.prod.outlook.com> (raw)
In-Reply-To: <95d3490d62f9d320e61efa10cba7424a6f626f66.1597166808.git.crobinso@redhat.com>

Reviewed-by: Yuwei Chen<yuwei.chen@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.feng@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Cole Robinson <crobinso@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 <crobinso@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
> 
> 
> 


  reply	other threads:[~2020-08-13  0:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-11 17:28 [PATCH 0/2] BaseTools: Python 3.9 fixes Cole
2020-08-11 17:28 ` [PATCH 1/2] BaseTools: fix ucs-2 lookup on python 3.9 Cole
2020-08-13  0:16   ` [edk2-devel] " Yuwei Chen
2020-08-14  1:20   ` Bob Feng
2020-08-11 17:28 ` [PATCH 2/2] BaseTools: Work around array.array.tostring() removal in " Cole
2020-08-13  0:16   ` Yuwei Chen [this message]
2020-08-14  1:20   ` Bob Feng
2020-08-17 17:07 ` [edk2-devel] [PATCH 0/2] BaseTools: Python 3.9 fixes Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM5PR11MB1594FAB1F844EAF288C5BD2D96430@DM5PR11MB1594.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox