<div dir="ltr">Thank you for the review Michael. <a class="gmail_plusreply" id="plusReplyChip-0" href="mailto:rebecca@bsdio.com" tabindex="-1">@Rebecca Cran</a>, <a class="gmail_plusreply" id="plusReplyChip-1" href="mailto:gaoliming@byosoft.com.cn" tabindex="-1">@Liming Gao</a> 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.<div><br></div><div>Thanks,</div><div>Joey</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 27, 2023 at 10:21 AM Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thank you for fixing this.<br>
<br>
Reviewed-by: Michael D Kinney <<a href="mailto:michael.d.kinney@intel.com" target="_blank">michael.d.kinney@intel.com</a>><br>
<br>
> -----Original Message-----<br>
> From: Joey Vagedes <<a href="mailto:joey.vagedes@gmail.com" target="_blank">joey.vagedes@gmail.com</a>><br>
> Sent: Tuesday, June 27, 2023 9:27 AM<br>
> To: <a href="mailto:devel@edk2.groups.io" target="_blank">devel@edk2.groups.io</a><br>
> Cc: Rebecca Cran <<a href="mailto:rebecca@bsdio.com" target="_blank">rebecca@bsdio.com</a>>; Gao, Liming<br>
> <<a href="mailto:gaoliming@byosoft.com.cn" target="_blank">gaoliming@byosoft.com.cn</a>>; Feng, Bob C <<a href="mailto:bob.c.feng@intel.com" target="_blank">bob.c.feng@intel.com</a>>; Chen,<br>
> Christine <<a href="mailto:yuwei.chen@intel.com" target="_blank">yuwei.chen@intel.com</a>>; Kinney, Michael D<br>
> <<a href="mailto:michael.d.kinney@intel.com" target="_blank">michael.d.kinney@intel.com</a>><br>
> Subject: [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation<br>
> <br>
> Removes the dependency on xdrlib and replaces it with custom logic to<br>
> pack a per the xdr requirements. Necessary as xdrlib is being deprecated<br>
> in python 3.13.<br>
> <br>
> Cc: Rebecca Cran <<a href="mailto:rebecca@bsdio.com" target="_blank">rebecca@bsdio.com</a>><br>
> Cc: Liming Gao <<a href="mailto:gaoliming@byosoft.com.cn" target="_blank">gaoliming@byosoft.com.cn</a>><br>
> Cc: Bob Feng <<a href="mailto:bob.c.feng@intel.com" target="_blank">bob.c.feng@intel.com</a>><br>
> Cc: Yuwei Chen <<a href="mailto:yuwei.chen@intel.com" target="_blank">yuwei.chen@intel.com</a>><br>
> Cc: Michael D Kinney <<a href="mailto:michael.d.kinney@intel.com" target="_blank">michael.d.kinney@intel.com</a>><br>
> Signed-off-by: Joey Vagedes <<a href="mailto:joeyvagedes@gmail.com" target="_blank">joeyvagedes@gmail.com</a>><br>
> ---<br>
>  BaseTools/Scripts/BinToPcd.py | 19 +++++++++++++++----<br>
>  1 file changed, 15 insertions(+), 4 deletions(-)<br>
> <br>
> diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py<br>
> index 3bc557b8412c..460c08b7f7cd 100644<br>
> --- a/BaseTools/Scripts/BinToPcd.py<br>
> +++ b/BaseTools/Scripts/BinToPcd.py<br>
> @@ -14,6 +14,9 @@ import sys<br>
>  import argparse<br>
> <br>
>  import re<br>
> <br>
>  import xdrlib<br>
> <br>
> +import io<br>
> <br>
> +import struct<br>
> <br>
> +import math<br>
> <br>
> <br>
> <br>
>  #<br>
> <br>
>  # Globals for help information<br>
> <br>
> @@ -46,16 +49,24 @@ if __name__ == '__main__':<br>
>              raise argparse.ArgumentTypeError (Message)<br>
> <br>
>          return Argument<br>
> <br>
> <br>
> <br>
> +    def XdrPackBuffer (buffer):<br>
> <br>
> +        packed_bytes = io.BytesIO()<br>
> <br>
> +        for unpacked_bytes in buffer:<br>
> <br>
> +            n = len(unpacked_bytes)<br>
> <br>
> +            packed_bytes.write(struct.pack('>L',n))<br>
> <br>
> +            data = unpacked_bytes[:n]<br>
> <br>
> +            n = math.ceil(n/4)*4<br>
> <br>
> +            data = data + (n - len(data)) * b'\0'<br>
> <br>
> +            packed_bytes.write(data)<br>
> <br>
> +        return packed_bytes.getvalue()<br>
> <br>
> +<br>
> <br>
>      def ByteArray (Buffer, Xdr = False):<br>
> <br>
>          if Xdr:<br>
> <br>
>              #<br>
> <br>
>              # If Xdr flag is set then encode data using the Variable-<br>
> Length Opaque<br>
> <br>
>              # Data format of RFC 4506 External Data Representation<br>
> Standard (XDR).<br>
> <br>
>              #<br>
> <br>
> -            XdrEncoder = xdrlib.Packer ()<br>
> <br>
> -            for Item in Buffer:<br>
> <br>
> -                XdrEncoder.pack_bytes (Item)<br>
> <br>
> -            Buffer = bytearray (XdrEncoder.get_buffer ())<br>
> <br>
> +            Buffer = bytearray (XdrPackBuffer (Buffer))<br>
> <br>
>          else:<br>
> <br>
>              #<br>
> <br>
>              # If Xdr flag is not set, then concatenate all the data<br>
> <br>
> --<br>
> 2.41.0.windows.1<br>
<br>
</blockquote></div>


<div width="1" style="color:white;clear:both">_._,_._,_</div>
<hr>


Groups.io Links:<p>


  
    You receive all messages sent to this group.
  
  


<p>
<a target="_blank" href="https://edk2.groups.io/g/devel/message/106911">View/Reply Online (#106911)</a> |


  

|

  <a target="_blank" href="https://groups.io/mt/99813913/1813853">Mute This Topic</a>


| <a href="https://edk2.groups.io/g/devel/post">New Topic</a>

<br>




<a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> |
<a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |

<a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>

 [edk2-devel-archive@redhat.com]<br>
<div width="1" style="color:white;clear:both">_._,_._,_</div>