public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/1] BaseTools: replace fromstring and tostring Method.
@ 2020-11-13  6:04 Mingyue Liang
  2020-12-22  2:06 ` Bob Feng
  0 siblings, 1 reply; 4+ messages in thread
From: Mingyue Liang @ 2020-11-13  6:04 UTC (permalink / raw)
  To: devel; +Cc: Bob Feng, Liming Gao, Yuwei Chen

Because after Python 3.2, array.tostring and
array.fromstring method is renamed tobytes
and frombytes,so it needs to be modified to
support python2 and python3 methods.

Signed-off-by: Mingyue Liang <mingyuex.liang@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Cc: Mingyue Liang <mingyuex.liang@intel.com>
---
 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 791fcdfeaed8..68cc9f1239f5 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.fromlist(array('B',TmpData).tolist())
         except:
             TmpData = DeCompress('Framework', self[self._HEADER_SIZE_:])
             DecData = array('B')
-            DecData.fromstring(TmpData)
+            DecData.fromlist(array('B',TmpData).tolist())
 
         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(b"".join(list(map(lambda x:bytes([x]), self[0:-2].tolist()))))[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.fromlist(array('B',TmpData).tolist())
                 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.fromlist(array('B',TmpData).tolist())
                 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 dc1727c4666d..83fa48187996 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.fromlist(array('B',Ui.encode('utf-16-le')).tolist())
                 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, b"".join(list(map(lambda x:bytes([x]), SectionData.tolist()))))
 
         elif Ver:
             Cmd += ("-n", Ver)
-- 
2.29.2.windows.2


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

* Re: [PATCH 1/1] BaseTools: replace fromstring and tostring Method.
  2020-11-13  6:04 [PATCH 1/1] BaseTools: replace fromstring and tostring Method Mingyue Liang
@ 2020-12-22  2:06 ` Bob Feng
  2021-01-07 12:07   ` [edk2-devel] " Laszlo Ersek
  0 siblings, 1 reply; 4+ messages in thread
From: Bob Feng @ 2020-12-22  2:06 UTC (permalink / raw)
  To: Liang, MingyueX, devel@edk2.groups.io; +Cc: Liming Gao, Chen, Christine

Reviewed-by: Bob Feng <bob.c.feng@intel.com>


-----Original Message-----
From: Mingyue Liang <mingyuex.liang@intel.com> 
Sent: Friday, November 13, 2020 2:04 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@intel.com>
Subject: [PATCH 1/1] BaseTools: replace fromstring and tostring Method.

Because after Python 3.2, array.tostring and array.fromstring method is renamed tobytes and frombytes,so it needs to be modified to support python2 and python3 methods.

Signed-off-by: Mingyue Liang <mingyuex.liang@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Cc: Mingyue Liang <mingyuex.liang@intel.com>
---
 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 791fcdfeaed8..68cc9f1239f5 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.fromlist(array('B',TmpData).tolist())
         except:
             TmpData = DeCompress('Framework', self[self._HEADER_SIZE_:])
             DecData = array('B')
-            DecData.fromstring(TmpData)
+            DecData.fromlist(array('B',TmpData).tolist())
 
         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(b"".join(list(map(lambda 
+ x:bytes([x]), self[0:-2].tolist()))))[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.fromlist(array('B',TmpData).tolist())
                 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.fromlist(array('B',TmpData).tolist())
                 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 dc1727c4666d..83fa48187996 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.fromlist(array('B',Ui.encode('utf-16-le')).tolist())
                 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, b"".join(list(map(lambda 
+ x:bytes([x]), SectionData.tolist()))))
 
         elif Ver:
             Cmd += ("-n", Ver)
--
2.29.2.windows.2


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

* Re: [edk2-devel] [PATCH 1/1] BaseTools: replace fromstring and tostring Method.
  2020-12-22  2:06 ` Bob Feng
@ 2021-01-07 12:07   ` Laszlo Ersek
  2021-01-08  9:06     ` 回复: " gaoliming
  0 siblings, 1 reply; 4+ messages in thread
From: Laszlo Ersek @ 2021-01-07 12:07 UTC (permalink / raw)
  To: devel, bob.c.feng, Liang, MingyueX; +Cc: Liming Gao, Chen, Christine

On 12/22/20 03:06, Bob Feng wrote:
> Reviewed-by: Bob Feng <bob.c.feng@intel.com>

Has this patch been merged?

Thanks
Laszlo

> -----Original Message-----
> From: Mingyue Liang <mingyuex.liang@intel.com> 
> Sent: Friday, November 13, 2020 2:04 PM
> To: devel@edk2.groups.io
> Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@intel.com>
> Subject: [PATCH 1/1] BaseTools: replace fromstring and tostring Method.
> 
> Because after Python 3.2, array.tostring and array.fromstring method is renamed tobytes and frombytes,so it needs to be modified to support python2 and python3 methods.
> 
> Signed-off-by: Mingyue Liang <mingyuex.liang@intel.com>
> Cc: Bob Feng <bob.c.feng@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Yuwei Chen <yuwei.chen@intel.com>
> Cc: Mingyue Liang <mingyuex.liang@intel.com>
> ---
>  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 791fcdfeaed8..68cc9f1239f5 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.fromlist(array('B',TmpData).tolist())
>          except:
>              TmpData = DeCompress('Framework', self[self._HEADER_SIZE_:])
>              DecData = array('B')
> -            DecData.fromstring(TmpData)
> +            DecData.fromlist(array('B',TmpData).tolist())
>  
>          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(b"".join(list(map(lambda 
> + x:bytes([x]), self[0:-2].tolist()))))[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.fromlist(array('B',TmpData).tolist())
>                  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.fromlist(array('B',TmpData).tolist())
>                  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 dc1727c4666d..83fa48187996 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.fromlist(array('B',Ui.encode('utf-16-le')).tolist())
>                  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, b"".join(list(map(lambda 
> + x:bytes([x]), SectionData.tolist()))))
>  
>          elif Ver:
>              Cmd += ("-n", Ver)
> --
> 2.29.2.windows.2
> 
> 
> 
> 
> 
> 


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

* 回复: [edk2-devel] [PATCH 1/1] BaseTools: replace fromstring and tostring Method.
  2021-01-07 12:07   ` [edk2-devel] " Laszlo Ersek
@ 2021-01-08  9:06     ` gaoliming
  0 siblings, 0 replies; 4+ messages in thread
From: gaoliming @ 2021-01-08  9:06 UTC (permalink / raw)
  To: devel, lersek, bob.c.feng, 'Liang, MingyueX'
  Cc: 'Chen, Christine'

Laszlo:
  Bob updated the patch and merged it. https://github.com/tianocore/edk2/pull/1296

Thanks
Liming
> -----邮件原件-----
> 发件人: bounce+27952+69917+4905953+8761045@groups.io
> <bounce+27952+69917+4905953+8761045@groups.io> 代表 Laszlo Ersek
> 发送时间: 2021年1月7日 20:08
> 收件人: devel@edk2.groups.io; bob.c.feng@intel.com; Liang, MingyueX
> <mingyuex.liang@intel.com>
> 抄送: Liming Gao <gaoliming@byosoft.com.cn>; Chen, Christine
> <yuwei.chen@intel.com>
> 主题: Re: [edk2-devel] [PATCH 1/1] BaseTools: replace fromstring and tostring
> Method.
> 
> On 12/22/20 03:06, Bob Feng wrote:
> > Reviewed-by: Bob Feng <bob.c.feng@intel.com>
> 
> Has this patch been merged?
> 
> Thanks
> Laszlo
> 
> > -----Original Message-----
> > From: Mingyue Liang <mingyuex.liang@intel.com>
> > Sent: Friday, November 13, 2020 2:04 PM
> > To: devel@edk2.groups.io
> > Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@intel.com>
> > Subject: [PATCH 1/1] BaseTools: replace fromstring and tostring Method.
> >
> > Because after Python 3.2, array.tostring and array.fromstring method is
> renamed tobytes and frombytes,so it needs to be modified to support python2
> and python3 methods.
> >
> > Signed-off-by: Mingyue Liang <mingyuex.liang@intel.com>
> > Cc: Bob Feng <bob.c.feng@intel.com>
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > Cc: Yuwei Chen <yuwei.chen@intel.com>
> > Cc: Mingyue Liang <mingyuex.liang@intel.com>
> > ---
> >  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 791fcdfeaed8..68cc9f1239f5 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.fromlist(array('B',TmpData).tolist())
> >          except:
> >              TmpData = DeCompress('Framework',
> self[self._HEADER_SIZE_:])
> >              DecData = array('B')
> > -            DecData.fromstring(TmpData)
> > +            DecData.fromlist(array('B',TmpData).tolist())
> >
> >          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(b"".join(list(map(lambda
> > + x:bytes([x]), self[0:-2].tolist()))))[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.fromlist(array('B',TmpData).tolist())
> >                  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.fromlist(array('B',TmpData).tolist())
> >                  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 dc1727c4666d..83fa48187996 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.fromlist(array('B',Ui.encode('utf-16-le')).tolist())
> >                  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, b"".join(list(map(lambda
> > + x:bytes([x]), SectionData.tolist()))))
> >
> >          elif Ver:
> >              Cmd += ("-n", Ver)
> > --
> > 2.29.2.windows.2
> >
> >
> >
> >
> >
> >
> 
> 
> 
> 
> 




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

end of thread, other threads:[~2021-01-08  9:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-13  6:04 [PATCH 1/1] BaseTools: replace fromstring and tostring Method Mingyue Liang
2020-12-22  2:06 ` Bob Feng
2021-01-07 12:07   ` [edk2-devel] " Laszlo Ersek
2021-01-08  9:06     ` 回复: " gaoliming

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