summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/GenFds/FvImageSection.py
diff options
context:
space:
mode:
authorFeng, Bob C <bob.c.feng@intel.com>2019-01-23 09:29:52 +0800
committerFeng, Bob C <bob.c.feng@intel.com>2019-02-01 11:09:24 +0800
commit7fa0e68afd658bda001aaccf616837a4a493a385 (patch)
treecfd28c6a5260de3adb85f00969302e65e411b315 /BaseTools/Source/Python/GenFds/FvImageSection.py
parent4a3773e5783d60f7142325667de2af53da662142 (diff)
downloadedk2-7fa0e68afd658bda001aaccf616837a4a493a385.tar.gz
edk2-7fa0e68afd658bda001aaccf616837a4a493a385.tar.bz2
edk2-7fa0e68afd658bda001aaccf616837a4a493a385.zip
BaseTools:ord() don't match in py2 and py3
In python2, the FvHeaderBuffer Type is a str In python3, the FvHeaderBuffer Type is a bytes 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/GenFds/FvImageSection.py')
-rw-r--r--BaseTools/Source/Python/GenFds/FvImageSection.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py
index 535b86ab5e..7ea931e1b5 100644
--- a/BaseTools/Source/Python/GenFds/FvImageSection.py
+++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
@@ -71,7 +71,10 @@ class FvImageSection(FvImageSectionClassObject):
# PI FvHeader is 0x48 byte
FvHeaderBuffer = FvFileObj.read(0x48)
# FV alignment position.
- FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)
+ if isinstance(FvHeaderBuffer[0x2E], str):
+ FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1F)
+ else:
+ FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)
FvFileObj.close()
if FvAlignmentValue > MaxFvAlignment:
MaxFvAlignment = FvAlignmentValue
@@ -121,7 +124,10 @@ class FvImageSection(FvImageSectionClassObject):
# PI FvHeader is 0x48 byte
FvHeaderBuffer = FvFileObj.read(0x48)
# FV alignment position.
- FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)
+ if isinstance(FvHeaderBuffer[0x2E], str):
+ FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1F)
+ else:
+ FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)
# FvAlignmentValue is larger than or equal to 1K
if FvAlignmentValue >= 0x400:
if FvAlignmentValue >= 0x100000: