From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mx.groups.io with SMTP id smtpd.web10.11495.1689262030670147440 for ; Thu, 13 Jul 2023 08:27:10 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Gx+2ETAo; spf=pass (domain: gmail.com, ip: 209.85.216.45, mailfrom: joey.vagedes@gmail.com) Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2640a8ceefdso527411a91.3 for ; Thu, 13 Jul 2023 08:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689262030; x=1691854030; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KeWlE5lzInK4hBJxprERh8MAzSVdpTxsnWGS6C2W7gw=; b=Gx+2ETAoAXuqyT2TvgGiCMF1+oJFFfBcsAWlzTpOa5HRtIMXs2JRqeby3Y2YC9KQM1 bdix8VfB6pzkF+BNFprXBERH7a+bqV6hy5MzL/APfvHDAh1+F1XxugykQ+CwVwZondL9 DWhENOBvrYOvUcEC7FCYaLPBxBNnKCZjZUMTmhKKxxusOJyiiqbmI20LLAdxw2Qyy3TR 2YHqyu00lh3lm+8bZrSZ8XNy6y847YpO0+qHE9w6OmdvVQKuuyRzok16VHwWuvv96oJZ Y8BueonJ4XJh8x14BjyJ2jdO78BRBZhE6AvKO2heY2wb04H58+kjUuQ3fS1W6+q68PLE w1HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689262030; x=1691854030; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KeWlE5lzInK4hBJxprERh8MAzSVdpTxsnWGS6C2W7gw=; b=TidLCU/pUMobUUPeTg6G4za4TyBdnSgiFtQKa9gA8Gm4c3EoOBri1RWfhQvELoGnez 98Taobk0KkiyQZUC0Yf5IfNAt8GeFQWyz5ITLrrMn2I7cm+voCNZ7DcZIBYuuZrdYV6e Ky7B449+shvxow/+Lvb0NGxwM2VdLmO1uObIUfSR61utyfyp4I5jY5a3CrzHEUvX9L3C pdkJpRLyTcl3THZ8o0BMhKzIOP2WQX4IuUbvxaT/rqMfyCLtMspZYKwIIvgZukr76B7A eQY/B+zJjDjT66ObwxVkBolar4toJUbz6/7gDbif2d1vnGDTzewvBLqAhEycl/J8BOuo 5bDA== X-Gm-Message-State: ABy/qLbNR8lhgIOsfnNXkSNtCcDANeMfsjGBu4DoLZGVTqL+ycO3++D+ 9VXhxlhKUtaMhmK6Wq/J8bck+ZuJM9V1Qgx3DjYbwQFb++g= X-Google-Smtp-Source: APBJJlGWCtWpq0327mQMOrWOzHbq0U9vZmWW/N9vgC+DKi/7vyCxGsZv2BcDrPNqoljC3oodNHdl1SNViD+scTMHkDY= X-Received: by 2002:a17:90a:6749:b0:260:e7ad:3659 with SMTP id c9-20020a17090a674900b00260e7ad3659mr1588586pjm.12.1689262030045; Thu, 13 Jul 2023 08:27:10 -0700 (PDT) MIME-Version: 1.0 References: <20230627162722.1030-1-joey.vagedes@gmail.com> <20230627162722.1030-2-joey.vagedes@gmail.com> In-Reply-To: From: "Joey Vagedes" Date: Thu, 13 Jul 2023 08:26:58 -0700 Message-ID: Subject: Re: [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation To: "Kinney, Michael D" Cc: "devel@edk2.groups.io" , Rebecca Cran , "Gao, Liming" , "Feng, Bob C" , "Chen, Christine" Content-Type: multipart/alternative; boundary="0000000000003bc71206005ff79d" --0000000000003bc71206005ff79d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you for the review Michael. @Rebecca Cran , @Limin= g Gao 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=E2=80=AFAM Kinney, Michael D < michael.d.kinney@intel.com> wrote: > Thank you for fixing this. > > Reviewed-by: Michael D Kinney > > > -----Original Message----- > > From: Joey Vagedes > > Sent: Tuesday, June 27, 2023 9:27 AM > > To: devel@edk2.groups.io > > Cc: Rebecca Cran ; Gao, Liming > > ; Feng, Bob C ; Chen, > > Christine ; Kinney, Michael D > > > > 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 deprecate= d > > in python 3.13. > > > > Cc: Rebecca Cran > > Cc: Liming Gao > > Cc: Bob Feng > > Cc: Yuwei Chen > > Cc: Michael D Kinney > > Signed-off-by: Joey Vagedes > > --- > > 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__ =3D=3D '__main__': > > raise argparse.ArgumentTypeError (Message) > > > > return Argument > > > > > > > > + def XdrPackBuffer (buffer): > > > > + packed_bytes =3D io.BytesIO() > > > > + for unpacked_bytes in buffer: > > > > + n =3D len(unpacked_bytes) > > > > + packed_bytes.write(struct.pack('>L',n)) > > > > + data =3D unpacked_bytes[:n] > > > > + n =3D math.ceil(n/4)*4 > > > > + data =3D data + (n - len(data)) * b'\0' > > > > + packed_bytes.write(data) > > > > + return packed_bytes.getvalue() > > > > + > > > > def ByteArray (Buffer, Xdr =3D 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 =3D xdrlib.Packer () > > > > - for Item in Buffer: > > > > - XdrEncoder.pack_bytes (Item) > > > > - Buffer =3D bytearray (XdrEncoder.get_buffer ()) > > > > + Buffer =3D bytearray (XdrPackBuffer (Buffer)) > > > > else: > > > > # > > > > # If Xdr flag is not set, then concatenate all the data > > > > -- > > 2.41.0.windows.1 > > --0000000000003bc71206005ff79d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you for the review Michael.=C2=A0@Rebecca Cran,=C2=A0@Liming G= ao=C2=A0have 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=E2=80=AFAM 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@ed= k2.groups.io
> Cc: Rebecca Cran <rebecca@bsdio.com>; Gao, Liming
> <gaol= iming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>; Chen,
> Christine <yuwei.chen@intel.com>; Kinney, Michael D
> <mi= chael.d.kinney@intel.com>
> Subject: [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecatio= n
>
> Removes the dependency on xdrlib and replaces it with custom logic to<= br> > pack a per the xdr requirements. Necessary as xdrlib is being deprecat= ed
> 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>
> ---
>=C2=A0 BaseTools/Scripts/BinToPcd.py | 19 +++++++++++++++----
>=C2=A0 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPc= d.py
> index 3bc557b8412c..460c08b7f7cd 100644
> --- a/BaseTools/Scripts/BinToPcd.py
> +++ b/BaseTools/Scripts/BinToPcd.py
> @@ -14,6 +14,9 @@ import sys
>=C2=A0 import argparse
>
>=C2=A0 import re
>
>=C2=A0 import xdrlib
>
> +import io
>
> +import struct
>
> +import math
>
>
>
>=C2=A0 #
>
>=C2=A0 # Globals for help information
>
> @@ -46,16 +49,24 @@ if __name__ =3D=3D '__main__':
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise argparse.Argumen= tTypeError (Message)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return Argument
>
>
>
> +=C2=A0 =C2=A0 def XdrPackBuffer (buffer):
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 packed_bytes =3D io.BytesIO()
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 for unpacked_bytes in buffer:
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 n =3D len(unpacked_bytes) >
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 packed_bytes.write(struct.p= ack('>L',n))
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D unpacked_bytes[:n]=
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 n =3D math.ceil(n/4)*4
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D data + (n - len(da= ta)) * b'\0'
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 packed_bytes.write(data) >
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return packed_bytes.getvalue()
>
> +
>
>=C2=A0 =C2=A0 =C2=A0 def ByteArray (Buffer, Xdr =3D False):
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if Xdr:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # If Xdr flag is set t= hen encode data using the Variable-
> Length Opaque
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # Data format of RFC 4= 506 External Data Representation
> Standard (XDR).
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 XdrEncoder =3D xdrlib.Packe= r ()
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for Item in Buffer:
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 XdrEncoder.pa= ck_bytes (Item)
>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Buffer =3D bytearray (XdrEn= coder.get_buffer ())
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Buffer =3D bytearray (XdrPa= ckBuffer (Buffer))
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 else:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # If Xdr flag is not s= et, then concatenate all the data
>
> --
> 2.41.0.windows.1

--0000000000003bc71206005ff79d--