public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools: array.fromstring and array.tostring removed in python 3.9
@ 2020-10-13  1:46 fengyunhua
  2020-10-19  7:51 ` 回复: " gaoliming
  0 siblings, 1 reply; 2+ messages in thread
From: fengyunhua @ 2020-10-13  1:46 UTC (permalink / raw)
  To: devel; +Cc: bob.c.feng, gaoliming

array.fromstring and array.tostring deprecated, and alias for
array.frombytes and array.tobytes. Deprecated since version 3.2,
have been removed in version python 3.9.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yunhua Feng <fengyunhua@byosoft.com.cn>
---
 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 791fcdfeae..08bb2de172 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.frombytes(TmpData)
         except:
             TmpData = DeCompress('Framework', self[self._HEADER_SIZE_:])
             DecData = array('B')
-            DecData.fromstring(TmpData)
+            DecData.frombytes(TmpData)
 
         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(self[0:-2].tobytes())[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.frombytes(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)
+                DecData.frombytes(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..124dc43199 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.frombytes(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, SectionData.tobytes())
 
         elif Ver:
             Cmd += ("-n", Ver)
-- 
2.27.0.windows.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* 回复: [PATCH] BaseTools: array.fromstring and array.tostring removed in python 3.9
  2020-10-13  1:46 [PATCH] BaseTools: array.fromstring and array.tostring removed in python 3.9 fengyunhua
@ 2020-10-19  7:51 ` gaoliming
  0 siblings, 0 replies; 2+ messages in thread
From: gaoliming @ 2020-10-19  7:51 UTC (permalink / raw)
  To: 'fengyunhua', devel; +Cc: bob.c.feng

Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>

> -----邮件原件-----
> 发件人: fengyunhua <fengyunhua@byosoft.com.cn>
> 发送时间: 2020年10月13日 9:47
> 收件人: devel@edk2.groups.io
> 抄送: bob.c.feng@intel.com; gaoliming@byosoft.com.cn
> 主题: [PATCH] BaseTools: array.fromstring and array.tostring removed in
> python 3.9
> 
> array.fromstring and array.tostring deprecated, and alias for
> array.frombytes and array.tobytes. Deprecated since version 3.2,
> have been removed in version python 3.9.
> 
> Cc: Bob Feng <bob.c.feng@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Signed-off-by: Yunhua Feng <fengyunhua@byosoft.com.cn>
> ---
>  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 791fcdfeae..08bb2de172 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.frombytes(TmpData)
>          except:
>              TmpData = DeCompress('Framework',
> self[self._HEADER_SIZE_:])
>              DecData = array('B')
> -            DecData.fromstring(TmpData)
> +            DecData.frombytes(TmpData)
> 
>          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(self[0:-2].tobytes())[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.frombytes(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)
> +                DecData.frombytes(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..124dc43199 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.frombytes(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, SectionData.tobytes())
> 
>          elif Ver:
>              Cmd += ("-n", Ver)
> --
> 2.27.0.windows.1
> 




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-19  7:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-13  1:46 [PATCH] BaseTools: array.fromstring and array.tostring removed in python 3.9 fengyunhua
2020-10-19  7:51 ` 回复: " gaoliming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox