* Re: [edk2-devel] [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation
2023-07-13 15:26 ` Joey Vagedes
@ 2023-07-13 15:56 ` Rebecca Cran
2023-07-17 1:07 ` 回复: " gaoliming
2023-08-02 3:09 ` [edk2-devel] 回复: " gaoliming via groups.io
2 siblings, 0 replies; 7+ messages in thread
From: Rebecca Cran @ 2023-07-13 15:56 UTC (permalink / raw)
To: devel, joeyvagedes, Kinney, Michael D
Cc: gaoliming, 'Bob Feng', 'Yuwei Chen'
Sorry I haven’t had a chance to look at it. I’ll try and find some time this weekend.
On Thu, Jul 13, 2023, at 9:26 AM, Joey Vagedes via groups.io wrote:
> Thank you for the review Michael. @Rebecca Cran
> <mailto:rebecca@bsdio.com>, @Liming Gao
> <mailto:gaoliming@byosoft.com.cn> have you had time to take a look at
> this? It is a fairly simple change, following the same logic as xdrlib
> with a few modifications to use some newer python functionality.
>
> Thanks,
> Joey
>
> On Tue, Jun 27, 2023 at 10:21 AM Kinney, Michael D
> <michael.d.kinney@intel.com> wrote:
>> Thank you for fixing this.
>>
>> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
>>
>> > -----Original Message-----
>> > From: Joey Vagedes <joey.vagedes@gmail.com>
>> > Sent: Tuesday, June 27, 2023 9:27 AM
>> > To: devel@edk2.groups.io
>> > Cc: Rebecca Cran <rebecca@bsdio.com>; Gao, Liming
>> > <gaoliming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>; Chen,
>> > Christine <yuwei.chen@intel.com>; Kinney, Michael D
>> > <michael.d.kinney@intel.com>
>> > Subject: [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation
>> >
>> > Removes the dependency on xdrlib and replaces it with custom logic to
>> > pack a per the xdr requirements. Necessary as xdrlib is being deprecated
>> > in python 3.13.
>> >
>> > Cc: Rebecca Cran <rebecca@bsdio.com>
>> > Cc: Liming Gao <gaoliming@byosoft.com.cn>
>> > Cc: Bob Feng <bob.c.feng@intel.com>
>> > Cc: Yuwei Chen <yuwei.chen@intel.com>
>> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> > Signed-off-by: Joey Vagedes <joeyvagedes@gmail.com>
>> > ---
>> > BaseTools/Scripts/BinToPcd.py | 19 +++++++++++++++----
>> > 1 file changed, 15 insertions(+), 4 deletions(-)
>> >
>> > diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py
>> > index 3bc557b8412c..460c08b7f7cd 100644
>> > --- a/BaseTools/Scripts/BinToPcd.py
>> > +++ b/BaseTools/Scripts/BinToPcd.py
>> > @@ -14,6 +14,9 @@ import sys
>> > import argparse
>> >
>> > import re
>> >
>> > import xdrlib
>> >
>> > +import io
>> >
>> > +import struct
>> >
>> > +import math
>> >
>> >
>> >
>> > #
>> >
>> > # Globals for help information
>> >
>> > @@ -46,16 +49,24 @@ if __name__ == '__main__':
>> > raise argparse.ArgumentTypeError (Message)
>> >
>> > return Argument
>> >
>> >
>> >
>> > + def XdrPackBuffer (buffer):
>> >
>> > + packed_bytes = io.BytesIO()
>> >
>> > + for unpacked_bytes in buffer:
>> >
>> > + n = len(unpacked_bytes)
>> >
>> > + packed_bytes.write(struct.pack('>L',n))
>> >
>> > + data = unpacked_bytes[:n]
>> >
>> > + n = math.ceil(n/4)*4
>> >
>> > + data = data + (n - len(data)) * b'\0'
>> >
>> > + packed_bytes.write(data)
>> >
>> > + return packed_bytes.getvalue()
>> >
>> > +
>> >
>> > def ByteArray (Buffer, Xdr = False):
>> >
>> > if Xdr:
>> >
>> > #
>> >
>> > # If Xdr flag is set then encode data using the Variable-
>> > Length Opaque
>> >
>> > # Data format of RFC 4506 External Data Representation
>> > Standard (XDR).
>> >
>> > #
>> >
>> > - XdrEncoder = xdrlib.Packer ()
>> >
>> > - for Item in Buffer:
>> >
>> > - XdrEncoder.pack_bytes (Item)
>> >
>> > - Buffer = bytearray (XdrEncoder.get_buffer ())
>> >
>> > + Buffer = bytearray (XdrPackBuffer (Buffer))
>> >
>> > else:
>> >
>> > #
>> >
>> > # If Xdr flag is not set, then concatenate all the data
>> >
>> > --
>> > 2.41.0.windows.1
>>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* 回复: [edk2-devel] [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation
2023-07-13 15:26 ` Joey Vagedes
2023-07-13 15:56 ` [edk2-devel] " Rebecca Cran
@ 2023-07-17 1:07 ` gaoliming
2023-08-02 3:09 ` [edk2-devel] 回复: " gaoliming via groups.io
2 siblings, 0 replies; 7+ messages in thread
From: gaoliming @ 2023-07-17 1:07 UTC (permalink / raw)
To: devel, joeyvagedes, 'Kinney, Michael D'
Cc: 'Rebecca Cran', 'Feng, Bob C',
'Chen, Christine'
[-- Attachment #1: Type: text/plain, Size: 4309 bytes --]
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Joey Vagedes via groups.io
发送时间: 2023年7月13日 23:27
收件人: Kinney, Michael D <michael.d.kinney@intel.com>
抄送: devel@edk2.groups.io; Rebecca Cran <rebecca@bsdio.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>; Chen, Christine <yuwei.chen@intel.com>
主题: Re: [edk2-devel] [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation
Thank you for the review Michael. @Rebecca Cran <mailto:rebecca@bsdio.com> , @Liming Gao <mailto:gaoliming@byosoft.com.cn> have you had time to take a look at this? It is a fairly simple change, following the same logic as xdrlib with a few modifications to use some newer python functionality.
Thanks,
Joey
On Tue, Jun 27, 2023 at 10:21 AM Kinney, Michael D <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com> > wrote:
Thank you for fixing this.
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com> >
> -----Original Message-----
> From: Joey Vagedes <joey.vagedes@gmail.com <mailto:joey.vagedes@gmail.com> >
> Sent: Tuesday, June 27, 2023 9:27 AM
> To: devel@edk2.groups.io <mailto:devel@edk2.groups.io>
> Cc: Rebecca Cran <rebecca@bsdio.com <mailto:rebecca@bsdio.com> >; Gao, Liming
> <gaoliming@byosoft.com.cn <mailto:gaoliming@byosoft.com.cn> >; Feng, Bob C <bob.c.feng@intel.com <mailto:bob.c.feng@intel.com> >; Chen,
> Christine <yuwei.chen@intel.com <mailto:yuwei.chen@intel.com> >; Kinney, Michael D
> <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com> >
> Subject: [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation
>
> Removes the dependency on xdrlib and replaces it with custom logic to
> pack a per the xdr requirements. Necessary as xdrlib is being deprecated
> in python 3.13.
>
> Cc: Rebecca Cran <rebecca@bsdio.com <mailto:rebecca@bsdio.com> >
> Cc: Liming Gao <gaoliming@byosoft.com.cn <mailto:gaoliming@byosoft.com.cn> >
> Cc: Bob Feng <bob.c.feng@intel.com <mailto:bob.c.feng@intel.com> >
> Cc: Yuwei Chen <yuwei.chen@intel.com <mailto:yuwei.chen@intel.com> >
> Cc: Michael D Kinney <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com> >
> Signed-off-by: Joey Vagedes <joeyvagedes@gmail.com <mailto:joeyvagedes@gmail.com> >
> ---
> BaseTools/Scripts/BinToPcd.py | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py
> index 3bc557b8412c..460c08b7f7cd 100644
> --- a/BaseTools/Scripts/BinToPcd.py
> +++ b/BaseTools/Scripts/BinToPcd.py
> @@ -14,6 +14,9 @@ import sys
> import argparse
>
> import re
>
> import xdrlib
>
> +import io
>
> +import struct
>
> +import math
>
>
>
> #
>
> # Globals for help information
>
> @@ -46,16 +49,24 @@ if __name__ == '__main__':
> raise argparse.ArgumentTypeError (Message)
>
> return Argument
>
>
>
> + def XdrPackBuffer (buffer):
>
> + packed_bytes = io.BytesIO()
>
> + for unpacked_bytes in buffer:
>
> + n = len(unpacked_bytes)
>
> + packed_bytes.write(struct.pack('>L',n))
>
> + data = unpacked_bytes[:n]
>
> + n = math.ceil(n/4)*4
>
> + data = data + (n - len(data)) * b'\0'
>
> + packed_bytes.write(data)
>
> + return packed_bytes.getvalue()
>
> +
>
> def ByteArray (Buffer, Xdr = False):
>
> if Xdr:
>
> #
>
> # If Xdr flag is set then encode data using the Variable-
> Length Opaque
>
> # Data format of RFC 4506 External Data Representation
> Standard (XDR).
>
> #
>
> - XdrEncoder = xdrlib.Packer ()
>
> - for Item in Buffer:
>
> - XdrEncoder.pack_bytes (Item)
>
> - Buffer = bytearray (XdrEncoder.get_buffer ())
>
> + Buffer = bytearray (XdrPackBuffer (Buffer))
>
> else:
>
> #
>
> # If Xdr flag is not set, then concatenate all the data
>
> --
> 2.41.0.windows.1
[-- Attachment #2: Type: text/html, Size: 10014 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [edk2-devel] 回复: [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation
2023-07-13 15:26 ` Joey Vagedes
2023-07-13 15:56 ` [edk2-devel] " Rebecca Cran
2023-07-17 1:07 ` 回复: " gaoliming
@ 2023-08-02 3:09 ` gaoliming via groups.io
2 siblings, 0 replies; 7+ messages in thread
From: gaoliming via groups.io @ 2023-08-02 3:09 UTC (permalink / raw)
To: 'Joey Vagedes', 'Kinney, Michael D'
Cc: devel, 'Rebecca Cran', 'Feng, Bob C',
'Chen, Christine'
[-- Attachment #1: Type: text/plain, Size: 4627 bytes --]
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> I will merge it today.
Thanks
Liming
发件人: Joey Vagedes <joey.vagedes@gmail.com>
发送时间: 2023年7月13日 23:27
收件人: Kinney, Michael D <michael.d.kinney@intel.com>
抄送: devel@edk2.groups.io; Rebecca Cran <rebecca@bsdio.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>; Chen, Christine <yuwei.chen@intel.com>
主题: Re: [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation
Thank you for the review Michael. @Rebecca Cran <mailto:rebecca@bsdio.com> , @Liming Gao <mailto:gaoliming@byosoft.com.cn> have you had time to take a look at this? It is a fairly simple change, following the same logic as xdrlib with a few modifications to use some newer python functionality.
Thanks,
Joey
On Tue, Jun 27, 2023 at 10:21 AM Kinney, Michael D <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com> > wrote:
Thank you for fixing this.
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com> >
> -----Original Message-----
> From: Joey Vagedes <joey.vagedes@gmail.com <mailto:joey.vagedes@gmail.com> >
> Sent: Tuesday, June 27, 2023 9:27 AM
> To: devel@edk2.groups.io <mailto:devel@edk2.groups.io>
> Cc: Rebecca Cran <rebecca@bsdio.com <mailto:rebecca@bsdio.com> >; Gao, Liming
> <gaoliming@byosoft.com.cn <mailto:gaoliming@byosoft.com.cn> >; Feng, Bob C <bob.c.feng@intel.com <mailto:bob.c.feng@intel.com> >; Chen,
> Christine <yuwei.chen@intel.com <mailto:yuwei.chen@intel.com> >; Kinney, Michael D
> <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com> >
> Subject: [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation
>
> Removes the dependency on xdrlib and replaces it with custom logic to
> pack a per the xdr requirements. Necessary as xdrlib is being deprecated
> in python 3.13.
>
> Cc: Rebecca Cran <rebecca@bsdio.com <mailto:rebecca@bsdio.com> >
> Cc: Liming Gao <gaoliming@byosoft.com.cn <mailto:gaoliming@byosoft.com.cn> >
> Cc: Bob Feng <bob.c.feng@intel.com <mailto:bob.c.feng@intel.com> >
> Cc: Yuwei Chen <yuwei.chen@intel.com <mailto:yuwei.chen@intel.com> >
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Signed-off-by: Joey Vagedes <joeyvagedes@gmail.com <mailto:joeyvagedes@gmail.com> >
> ---
> BaseTools/Scripts/BinToPcd.py | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py
> index 3bc557b8412c..460c08b7f7cd 100644
> --- a/BaseTools/Scripts/BinToPcd.py
> +++ b/BaseTools/Scripts/BinToPcd.py
> @@ -14,6 +14,9 @@ import sys
> import argparse
>
> import re
>
> import xdrlib
>
> +import io
>
> +import struct
>
> +import math
>
>
>
> #
>
> # Globals for help information
>
> @@ -46,16 +49,24 @@ if __name__ == '__main__':
> raise argparse.ArgumentTypeError (Message)
>
> return Argument
>
>
>
> + def XdrPackBuffer (buffer):
>
> + packed_bytes = io.BytesIO()
>
> + for unpacked_bytes in buffer:
>
> + n = len(unpacked_bytes)
>
> + packed_bytes.write(struct.pack('>L',n))
>
> + data = unpacked_bytes[:n]
>
> + n = math.ceil(n/4)*4
>
> + data = data + (n - len(data)) * b'\0'
>
> + packed_bytes.write(data)
>
> + return packed_bytes.getvalue()
>
> +
>
> def ByteArray (Buffer, Xdr = False):
>
> if Xdr:
>
> #
>
> # If Xdr flag is set then encode data using the Variable-
> Length Opaque
>
> # Data format of RFC 4506 External Data Representation
> Standard (XDR).
>
> #
>
> - XdrEncoder = xdrlib.Packer ()
>
> - for Item in Buffer:
>
> - XdrEncoder.pack_bytes (Item)
>
> - Buffer = bytearray (XdrEncoder.get_buffer ())
>
> + Buffer = bytearray (XdrPackBuffer (Buffer))
>
> else:
>
> #
>
> # If Xdr flag is not set, then concatenate all the data
>
> --
> 2.41.0.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107439): https://edk2.groups.io/g/devel/message/107439
Mute This Topic: https://groups.io/mt/100498650/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 10616 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread