From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mx.groups.io with SMTP id smtpd.web10.2933.1687883257970851343 for ; Tue, 27 Jun 2023 09:27:38 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@gmail.com header.s=20221208 header.b=YzBfOjgi; spf=pass (domain: gmail.com, ip: 209.85.214.173, mailfrom: joey.vagedes@gmail.com) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1b80bce2592so13198495ad.2 for ; Tue, 27 Jun 2023 09:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687883257; x=1690475257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BG6izhjfvqTFhwEbSIe4vSKRI+dDDX8zd9vMcQMbCl8=; b=YzBfOjgihpAw2SXlV8Cayo9C1Rvcoab2F7vvEO/fFZq/c/GpF3FZt07nFQqBrw/yGd lPe+DqYx6qUHR82a3YYhr1aH2u+SgCmjtQ5vqfzYaTOJSZ0JwSj+C4CTNAlP4Tabwrjp 4PXbybyy3sK5U+ZLBfzY1i29hqzASM/ifFX+oU1RpBSrvud2y9USM+NSKvhWVnFFcAu/ 4T+ntxgwHqxPlzw6hV37Tq2JK+fpAV2tVzuF8OQv21zeo7PYHvxBq/DvIX7mkwduV9Dx yn7Wp1IUsJeo69saOEV+lpe+yIG5/QSYueiSqDNag6YUXQKmeM+5tEXnHNLQvEVpB5gB FbUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687883257; x=1690475257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BG6izhjfvqTFhwEbSIe4vSKRI+dDDX8zd9vMcQMbCl8=; b=EYqKwMJCi27hJc7E8hbzjyz2E++Ck49Dop1xYqnyTNx0gLKkgR4MUlXo9GNefoe29w 4bDMxRW6bBz7CHL7MomBsGtP5dl6a2VLCXziNVmorDnhupLMTdKtVcprYMbH5TkzU3yD 3EO1aYwGAZoFhr2VHIQDQzGMio9o3nzHBytcyP5YxJyQfG+YBB5P5lfNuU2XdSOQ5m4r I9eNycPVyRRLZIKXO5SOIhPb1C7wAfOrXLXvEk3HVh2ZUXYSXD+3Npl6KiqqwcbFx9yd 2p/ukpC78iuFT8tL8Y5cTY8dJyqBFHsAue/5QuOtgW+RB+ATyzgbxRHEnDZY9O0JpFSr rPNA== X-Gm-Message-State: AC+VfDy+b59YZXrHchm9X6ND/oqJtF+SLmVQeKO5Q3s+v5/D1hHWhAWT faelCDgn5iY58mfrAtEz8KOAQkALyw4S76jN X-Google-Smtp-Source: ACHHUZ4uiMsqnu36rE+jtAE3hX+YRux1Hhn5xP/kw+ImaGWM2msfXsWfNHa5mVdVhgBzKLgY4sSLIw== X-Received: by 2002:a17:903:18b:b0:1b5:2c0b:22d3 with SMTP id z11-20020a170903018b00b001b52c0b22d3mr9530583plg.14.1687883257153; Tue, 27 Jun 2023 09:27:37 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2001:4898:80e8:36:e1a8:b1a0:47f3:b1d5]) by smtp.gmail.com with ESMTPSA id k9-20020a170902760900b001b54a88e6adsm6063992pll.309.2023.06.27.09.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 09:27:36 -0700 (PDT) From: Joey Vagedes To: devel@edk2.groups.io Cc: Rebecca Cran , Liming Gao , Bob Feng , Yuwei Chen , Michael D Kinney Subject: [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation Date: Tue, 27 Jun 2023 09:27:22 -0700 Message-ID: <20230627162722.1030-2-joey.vagedes@gmail.com> X-Mailer: git-send-email 2.41.0.windows.1 In-Reply-To: <20230627162722.1030-1-joey.vagedes@gmail.com> References: <20230627162722.1030-1-joey.vagedes@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 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=0D import re=0D import xdrlib=0D +import io=0D +import struct=0D +import math=0D =0D #=0D # Globals for help information=0D @@ -46,16 +49,24 @@ if __name__ =3D=3D '__main__': raise argparse.ArgumentTypeError (Message)=0D return Argument=0D =0D + def XdrPackBuffer (buffer):=0D + packed_bytes =3D io.BytesIO()=0D + for unpacked_bytes in buffer:=0D + n =3D len(unpacked_bytes)=0D + packed_bytes.write(struct.pack('>L',n))=0D + data =3D unpacked_bytes[:n]=0D + n =3D math.ceil(n/4)*4=0D + data =3D data + (n - len(data)) * b'\0'=0D + packed_bytes.write(data)=0D + return packed_bytes.getvalue()=0D +=0D def ByteArray (Buffer, Xdr =3D False):=0D if Xdr:=0D #=0D # If Xdr flag is set then encode data using the Variable-Lengt= h Opaque=0D # Data format of RFC 4506 External Data Representation Standar= d (XDR).=0D #=0D - XdrEncoder =3D xdrlib.Packer ()=0D - for Item in Buffer:=0D - XdrEncoder.pack_bytes (Item)=0D - Buffer =3D bytearray (XdrEncoder.get_buffer ())=0D + Buffer =3D bytearray (XdrPackBuffer (Buffer))=0D else:=0D #=0D # If Xdr flag is not set, then concatenate all the data=0D --=20 2.41.0.windows.1