correct open MapFile support python2 and python3 Cc: Bob Feng <bob.c.f...@intel.com> Cc: Liming Gao <liming....@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan <zhijux....@intel.com> --- BaseTools/Source/Python/BPDG/GenVpd.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Python/BPDG/GenVpd.py index b91837d3d6..71fcfc5ac3 100644 --- a/BaseTools/Source/Python/BPDG/GenVpd.py +++ b/BaseTools/Source/Python/BPDG/GenVpd.py @@ -649,11 +649,11 @@ class GenVPD : except: # Open failed EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" % self.VpdFileName, None) try : - fMapFile = open(MapFileName, "w", 0) + fMapFile = open(MapFileName, "w") except: # Open failed EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" % self.MapFileName, None) # Use a instance of BytesIO to cache data @@ -673,12 +673,16 @@ class GenVPD : EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." % self.MapFileName, None) # Write Vpd binary file fStringIO.seek (eachPcd.PcdBinOffset) if isinstance(eachPcd.PcdValue, list): - ValueList = [chr(Item) for Item in eachPcd.PcdValue] - fStringIO.write(''.join(ValueList)) + for i in range(len(eachPcd.PcdValue)): + Value = eachPcd.PcdValue[i:i + 1] + if isinstance(bytes(Value), str): + fStringIO.write(chr(Value[0])) + else: + fStringIO.write(bytes(Value)) else: fStringIO.write (eachPcd.PcdValue) try : fVpdFile.write (fStringIO.getvalue()) -- 2.20.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel