From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 37E2921A00AE6 for ; Fri, 3 Aug 2018 13:47:40 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Aug 2018 13:47:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,439,1526367600"; d="scan'208";a="59580700" Received: from mdkinney-mobl2.amr.corp.intel.com ([10.254.66.232]) by fmsmga007.fm.intel.com with ESMTP; 03 Aug 2018 13:47:39 -0700 From: "Kinney, Michael D" To: edk2-devel@lists.01.org Cc: YanYan Sun , Yonghong Zhu , Liming Gao , Michael D Kinney Date: Fri, 3 Aug 2018 13:47:33 -0700 Message-Id: <20180803204733.6836-1-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 Subject: [Patch] BaseTools/BinToPcd: Open output file as text file X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 20:47:41 -0000 https://bugzilla.tianocore.org/show_bug.cgi?id=1069 Undo changes from following commit: https://github.com/tianocore/edk2/commit/83964ebc5e74549d6efc7134af19150a0b2079aa Change the open mode for the output file from 'wb' to 'w' so the output file is written as a text file and not a binary file. This resolves the issue where the text file was not writable from Python 3.x and also removes b'' from output file when the string was encoded as a bytearray. Cc: YanYan Sun Cc: Yonghong Zhu Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney --- BaseTools/Scripts/BinToPcd.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py index 1495a36933..316cc6117f 100644 --- a/BaseTools/Scripts/BinToPcd.py +++ b/BaseTools/Scripts/BinToPcd.py @@ -70,8 +70,7 @@ if __name__ == '__main__': # # Return a PCD value of the form '{0x01, 0x02, ...}' along with the PCD length in bytes # - PcdValue = '{' + ', '.join (['0x{Byte:02X}'.format (Byte = Item) for Item in Buffer]) + '}' - return PcdValue.encode (), len (Buffer) + return '{' + (', '.join (['0x{Byte:02X}'.format (Byte = Item) for Item in Buffer])) + '}', len (Buffer) # # Create command line argument parser object @@ -81,7 +80,7 @@ if __name__ == '__main__': conflict_handler = 'resolve') parser.add_argument ("-i", "--input", dest = 'InputFile', type = argparse.FileType ('rb'), action='append', required = True, help = "Input binary filename. Multiple input files are combined into a single PCD.") - parser.add_argument ("-o", "--output", dest = 'OutputFile', type = argparse.FileType ('wb'), + parser.add_argument ("-o", "--output", dest = 'OutputFile', type = argparse.FileType ('w'), help = "Output filename for PCD value or PCD statement") parser.add_argument ("-p", "--pcd", dest = 'PcdName', type = ValidatePcdName, help = "Name of the PCD in the form .") -- 2.14.2.windows.3