From: Joey Vagedes <joey.vagedes@gmail.com>
To: devel@edk2.groups.io
Cc: Rebecca Cran <rebecca@bsdio.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Bob Feng <bob.c.feng@intel.com>,
Yuwei Chen <yuwei.chen@intel.com>,
Michael D Kinney <michael.d.kinney@intel.com>
Subject: [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation
Date: Tue, 27 Jun 2023 09:27:22 -0700 [thread overview]
Message-ID: <20230627162722.1030-2-joey.vagedes@gmail.com> (raw)
In-Reply-To: <20230627162722.1030-1-joey.vagedes@gmail.com>
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
next prev parent reply other threads:[~2023-06-27 16:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-27 16:27 [PATCH v1 0/1] BaseTools: BinToPcd: Resolve xdrlib deprecation Joey Vagedes
2023-06-27 16:27 ` Joey Vagedes [this message]
2023-06-27 17:20 ` [PATCH v1 1/1] " Michael D Kinney
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230627162722.1030-2-joey.vagedes@gmail.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox