From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.1399.1687886463170742653 for ; Tue, 27 Jun 2023 10:21:03 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=B4UEoG/N; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: michael.d.kinney@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687886463; x=1719422463; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=geJOGdurgXq/PfVW+TVguihJa58LLPq9zncXUcBmgv0=; b=B4UEoG/Nh3h7CdeEz9tAiUJb6/lXlIUJ97Mbyp2/CUS30ydREAIOlggW 8rwCO6qTh4SddEOQ6WyYpWVpCh6u1YLWkmZsQVOQjHtlRlOIchQ6txNYo U6aEZeSwtpEiMqfLFGALssK2jAC2oGvRCQ+3293WNUrLsvqwpF0eptKaX 3erCHAGO4sqaRrgBAMldVJjivkmuJey/OpEAuAN5TvkXphXRYWAjDW6mg BfOfu9GOC2bO3r3QE+l9whU8qZW8RzDHmJ3MexGwlz4X0m681kLbj+X/C BbpIYlwyZ2bSt7G76elnTrT945TpXYgDg14B+wjmYnVL3L9lNAspgEzzk Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10754"; a="359130463" X-IronPort-AV: E=Sophos;i="6.01,163,1684825200"; d="scan'208";a="359130463" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2023 10:21:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10754"; a="963271960" X-IronPort-AV: E=Sophos;i="6.01,163,1684825200"; d="scan'208";a="963271960" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga006.fm.intel.com with ESMTP; 27 Jun 2023 10:21:02 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 27 Jun 2023 10:21:02 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 27 Jun 2023 10:21:01 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Tue, 27 Jun 2023 10:21:01 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.48) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Tue, 27 Jun 2023 10:20:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SVV6MUK4Afuy1tzSDGGPUXZY5RiXIQybEduTEsp0hwaC9L6/DsbrnwpUJvYi0/Z/aKP1xi/3IJ1XIfpQCHU86/0xts7G97f3D6Cz6Ka6PKtSJQK+E4BvKA6L2c41noRICGp9JDUYi2FourGwrIZRJPCqu8rjoQ7udwnYciwddWesz6IUn1L8ks4bxwYtjFf4gz+XHbpB8gogtyGR/nuwxmnIDiYswqi/H4h9kiXUMq1vfDoftaJ7S+EvVQ6YOhf1rgAsrUmg5roaZO9X9uTknezAo3E0AvwsAF5/oU1IqR+jDsKXcqNuIf4ETWpRoBeWVmn/nIUjqd2xDVuugwGNPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9HvX1it3VCX5Eivt09Ekd5fxDddC5P8F+Ra6FPJiODA=; b=BDyuhKFNV6t0WAamETxBRgP4EaaUPHQJ/Vvze3TuCCl9nPyvpepM1VH3xJmOhBPwnrXhBgYK4xPdNLxst1BKHH1qZrJ9Kne8meNy6v3BaV3UMWpPnhifubkIbu4H4JE6CvLQauTXW/SGfT+6zyKT10YWjWzFk8KlEFPNY1QsUwTVUDCuEK5/fLU9KqgR24PSazj32KVBqGdxIIiX1Ds8BuCHaJKkW3Rt3EUrWkKCjYkjtBBfDyyaoN9zhz4Jyu4vMQiUHsl92kZP2H5A0K+hPIKd6li+1wXkCSMrRhmxMCYqkMohNPkrhFw5yB5oivs1aM6FiHDatgIPhdiiNN9VHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SA2PR11MB4938.namprd11.prod.outlook.com (2603:10b6:806:fb::14) by SN7PR11MB7706.namprd11.prod.outlook.com (2603:10b6:806:32c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Tue, 27 Jun 2023 17:20:30 +0000 Received: from SA2PR11MB4938.namprd11.prod.outlook.com ([fe80::f7a7:8a51:7ca5:4784]) by SA2PR11MB4938.namprd11.prod.outlook.com ([fe80::f7a7:8a51:7ca5:4784%7]) with mapi id 15.20.6521.024; Tue, 27 Jun 2023 17:20:30 +0000 From: "Michael D Kinney" To: Joey Vagedes , "devel@edk2.groups.io" CC: Rebecca Cran , "Gao, Liming" , "Feng, Bob C" , "Chen, Christine" , "Kinney, Michael D" Subject: Re: [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation Thread-Topic: [PATCH v1 1/1] BaseTools: BinToPcd: Resolve xdrlib deprecation Thread-Index: AQHZqRTTUi2hXCF3ZEGOQaiC20kpga+e5Qug Date: Tue, 27 Jun 2023 17:20:30 +0000 Message-ID: References: <20230627162722.1030-1-joey.vagedes@gmail.com> <20230627162722.1030-2-joey.vagedes@gmail.com> In-Reply-To: <20230627162722.1030-2-joey.vagedes@gmail.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA2PR11MB4938:EE_|SN7PR11MB7706:EE_ x-ms-office365-filtering-correlation-id: 338d4b57-c098-45ca-8a91-08db7732cebc x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: nX+mUWLMgqJ4nfnypWDmoHHVFx9hgwaGl/HsKCumaSR64TZ9XqCAt449yp56BLKx9pgsdzZUCcRfRU/9mh8Nwy5uATzHp87Lo4O5Ofun+iKU/NZDH/uZgySQsC8RKB9pFPmx+T5oYNH33ubsluFRZr+WBC5A+m5XCg47rKgIFJ7V2v2g5cMIlr+VV8Si33sRrz4YV5wAlhl7SzU+YqDAtQ381iAhLrME60yq02jwvr74dafQRNivrDwkowDOW7i42Q3UN5pQxOM66uqNjuKCwOlMxD37U+6+XzDQr53u7xH8fcvsNhgXNOPSOh+zMAOjaehqLKtnfgAEgVoxKvNTvr7gZ1anRceZWqj8RyneO14UMnHlcqe2tZv3LpLntdM5dJP/3P575SYAzaYu7pvBlHKknwqtwT+Oyxh0E0f8qjBr/Y+WXC5NeNgy7W72IOyWd5OrRplO91Po7/VDwDUNss+mnIRlZsayO8YH3crbfqC+k9Arq0XuwFm162ZdfaNGfGN/apId2OnX/os04PpPwwk7VSxriEwI/ad9FUfo7aNQNVzPSfcnJM4SM/xw6GLnVdK+rkaVCytRkvjQc8Del6+L1+OCww8XDOiN4SDXmDHEfe5Ue3CiebbgSMu0QpiB6voV+1N2Mky22iOdhlZkryQjtitCRoP3dPnC/K3SmiM= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA2PR11MB4938.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(6029001)(396003)(39860400002)(346002)(366004)(376002)(136003)(451199021)(82960400001)(122000001)(38100700002)(38070700005)(83380400001)(33656002)(86362001)(478600001)(110136005)(54906003)(9686003)(71200400001)(7696005)(8936002)(41300700001)(316002)(76116006)(8676002)(4326008)(55016003)(66476007)(66556008)(66946007)(107886003)(66446008)(64756008)(6506007)(186003)(53546011)(26005)(52536014)(5660300002)(2906002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?evyrVYrfX1HXUjDd7JmoiqbwR6d10eByJlDyBhxB8zLeLCq9Zh4tpDC0ZjqP?= =?us-ascii?Q?lzNSDAFoodmyLtMpqj6q4wMQuJz3V2eTr/mQBMzEVqIBZO3bRhTN1I+g9mav?= =?us-ascii?Q?obm0cGmKsxpRW3DIdY18tvNjEHgmaSHvzx3oDhb22a0PF9/uwM/WHjeKqCGR?= =?us-ascii?Q?E/ukSRUyxsbHhxzxgega50OT0PQFpt5BLQJCuwtV1rKD/Nkr+xkpvN4yDUty?= =?us-ascii?Q?xMZRqduwj9Zra9/B4TthtrRbgu5C9fWZ8cPMcY6YIYjfusPAxu/4cze7qItr?= =?us-ascii?Q?1sl55YKm4oRGxI5Kwmvd8YTk1DQtRFeSTAf5pdjeNE4AopFhR03VHeRNCbNm?= =?us-ascii?Q?MxRsCJ0geOmVQ8yGhWs3tohtrp9MUf5aq5ES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ii?Q?8Ln/D/Y+x0GiAguTCSbA5lN3xLwQJhX5xqGvyX/HOC9ft5IqXSsbBFnx/Jw4?= =?us-ascii?Q?rOakIOdQ1IX1v32p0XRa66rKw1YZAed1U7Xjwmazr3KUj1szT/lG9GT6MBFb?= =?us-ascii?Q?Tek32g5KZygFmKI5LOBKrUAK5Fb2zm52Oo9cR4nIZ+vqLhvmHZsUlAi75yc/?= =?us-ascii?Q?bYXkp0so8DVz9tlm2MwGtTW4SvI1xxMmKaCaZJl2kVsec1EHTBNRuxRLLrXt?= =?us-ascii?Q?n3ilK/XwFpidGUBD2uD45aZLka0gmT4R2eDlCHWwS63IS3/rb6K/UKqkh+7t?= =?us-ascii?Q?M0GYcQP6OWCHDN6qZ/szekoIR59GxEnrDkVZyK3xgMX0mowpckvB6pNghACf?= =?us-ascii?Q?sQ=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA2PR11MB4938.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 338d4b57-c098-45ca-8a91-08db7732cebc X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jun 2023 17:20:30.3254 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Ex0GXVNPJ1ijswiDS+GACbxcA/jeQKe3NpcfhStuasfIkFjNsIa8ZVrJR/l80hBrLl3VhpOePa9DOf0GLms2KUrQG+r8vzH+N1Ov9T9E8Fo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR11MB7706 Return-Path: michael.d.kinney@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 >=20 > 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. >=20 > 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(-) >=20 > diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.p= y > index 3bc557b8412c..460c08b7f7cd 100644 > --- a/BaseTools/Scripts/BinToPcd.py > +++ b/BaseTools/Scripts/BinToPcd.py > @@ -14,6 +14,9 @@ import sys > import argparse >=20 > import re >=20 > import xdrlib >=20 > +import io >=20 > +import struct >=20 > +import math >=20 >=20 >=20 > # >=20 > # Globals for help information >=20 > @@ -46,16 +49,24 @@ if __name__ =3D=3D '__main__': > raise argparse.ArgumentTypeError (Message) >=20 > return Argument >=20 >=20 >=20 > + def XdrPackBuffer (buffer): >=20 > + packed_bytes =3D io.BytesIO() >=20 > + for unpacked_bytes in buffer: >=20 > + n =3D len(unpacked_bytes) >=20 > + packed_bytes.write(struct.pack('>L',n)) >=20 > + data =3D unpacked_bytes[:n] >=20 > + n =3D math.ceil(n/4)*4 >=20 > + data =3D data + (n - len(data)) * b'\0' >=20 > + packed_bytes.write(data) >=20 > + return packed_bytes.getvalue() >=20 > + >=20 > def ByteArray (Buffer, Xdr =3D False): >=20 > if Xdr: >=20 > # >=20 > # If Xdr flag is set then encode data using the Variable- > Length Opaque >=20 > # Data format of RFC 4506 External Data Representation > Standard (XDR). >=20 > # >=20 > - XdrEncoder =3D xdrlib.Packer () >=20 > - for Item in Buffer: >=20 > - XdrEncoder.pack_bytes (Item) >=20 > - Buffer =3D bytearray (XdrEncoder.get_buffer ()) >=20 > + Buffer =3D bytearray (XdrPackBuffer (Buffer)) >=20 > else: >=20 > # >=20 > # If Xdr flag is not set, then concatenate all the data >=20 > -- > 2.41.0.windows.1