]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools:ord() don't match in py2 and py3
authorFeng, Bob C <bob.c.feng@intel.com>
Wed, 23 Jan 2019 01:29:52 +0000 (09:29 +0800)
committerFeng, Bob C <bob.c.feng@intel.com>
Fri, 1 Feb 2019 03:09:24 +0000 (11:09 +0800)
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>
BaseTools/Source/Python/GenFds/FvImageSection.py

index 535b86ab5ea902d5b8be51208957fd10b9529f52..7ea931e1b54fc1e49a3a3ea7ab6c7e104c10ef67 100644 (file)
@@ -71,7 +71,10 @@ class FvImageSection(FvImageSectionClassObject):
                     # PI FvHeader is 0x48 byte\r
                     FvHeaderBuffer = FvFileObj.read(0x48)\r
                     # FV alignment position.\r
                     # PI FvHeader is 0x48 byte\r
                     FvHeaderBuffer = FvFileObj.read(0x48)\r
                     # FV alignment position.\r
-                    FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)\r
+                    if isinstance(FvHeaderBuffer[0x2E], str):\r
+                        FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1F)\r
+                    else:\r
+                        FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)\r
                     FvFileObj.close()\r
                 if FvAlignmentValue > MaxFvAlignment:\r
                     MaxFvAlignment = FvAlignmentValue\r
                     FvFileObj.close()\r
                 if FvAlignmentValue > MaxFvAlignment:\r
                     MaxFvAlignment = FvAlignmentValue\r
@@ -121,7 +124,10 @@ class FvImageSection(FvImageSectionClassObject):
                         # PI FvHeader is 0x48 byte\r
                         FvHeaderBuffer = FvFileObj.read(0x48)\r
                         # FV alignment position.\r
                         # PI FvHeader is 0x48 byte\r
                         FvHeaderBuffer = FvFileObj.read(0x48)\r
                         # FV alignment position.\r
-                        FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)\r
+                        if isinstance(FvHeaderBuffer[0x2E], str):\r
+                            FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1F)\r
+                        else:\r
+                            FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)\r
                         # FvAlignmentValue is larger than or equal to 1K\r
                         if FvAlignmentValue >= 0x400:\r
                             if FvAlignmentValue >= 0x100000:\r
                         # FvAlignmentValue is larger than or equal to 1K\r
                         if FvAlignmentValue >= 0x400:\r
                             if FvAlignmentValue >= 0x100000:\r