summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/BPDG
diff options
context:
space:
mode:
authorFeng, Bob C <bob.c.feng@intel.com>2019-01-16 09:12:36 +0800
committerFeng, Bob C <bob.c.feng@intel.com>2019-02-01 11:09:21 +0800
commitf935bdd270bc501350f1451edd54584f7de114ac (patch)
treeadcb39f98f47347f2fe9d199f31d2dc937558df7 /BaseTools/Source/Python/BPDG
parent62cb98c254c8c24f610a427c948ca68ba43d7882 (diff)
downloadedk2-f935bdd270bc501350f1451edd54584f7de114ac.tar.gz
edk2-f935bdd270bc501350f1451edd54584f7de114ac.tar.bz2
edk2-f935bdd270bc501350f1451edd54584f7de114ac.zip
BaseTools:File open failed for VPD MapFile
correct open MapFile support python2 and python3 Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/BPDG')
-rw-r--r--BaseTools/Source/Python/BPDG/GenVpd.py10
1 files 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
@@ -651,7 +651,7 @@ class GenVPD :
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)
@@ -675,8 +675,12 @@ class GenVPD :
# 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)