From d943b0c339fe3d35ffdf9f580ccb7a55915c6854 Mon Sep 17 00:00:00 2001 From: "Feng, Bob C" Date: Wed, 23 Jan 2019 10:16:00 +0800 Subject: BaseTools: Handle the bytes and str difference Deal with bytes and str is different, remove the unicode(), correct open file parameter. Using utcfromtimestamp instead of fromtimestamp. Cc: Bob Feng Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan Tested-by: Laszlo Ersek Tested-by: Ard Biesheuvel Reviewed-by: Liming Gao Reviewed-by: Bob Feng --- BaseTools/Source/Python/Workspace/DscBuildData.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'BaseTools/Source/Python/Workspace/DscBuildData.py') diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 13b2cef59d..a96502b4bf 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -156,7 +156,14 @@ def GetDependencyList(FileStack, SearchPathList): continue if FileContent[0] == 0xff or FileContent[0] == 0xfe: - FileContent = unicode(FileContent, "utf-16") + FileContent = FileContent.decode('utf-16') + IncludedFileList = gIncludePattern.findall(FileContent) + else: + try: + FileContent = str(FileContent) + IncludedFileList = gIncludePattern.findall(FileContent) + except: + pass IncludedFileList = gIncludePattern.findall(FileContent) for Inc in IncludedFileList: @@ -1615,7 +1622,7 @@ class DscBuildData(PlatformBuildClassObject): FdfInfList = GlobalData.gFdfParser.Profile.InfList FdfModuleList = [PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch=self._Arch) for Inf in FdfInfList] AllModulePcds = set() - ModuleSet = set(self._Modules.keys() + FdfModuleList) + ModuleSet = set(list(self._Modules.keys()) + FdfModuleList) for ModuleFile in ModuleSet: ModuleData = self._Bdb[ModuleFile, self._Arch, self._Target, self._Toolchain] AllModulePcds = AllModulePcds | ModuleData.PcdsName @@ -1743,7 +1750,7 @@ class DscBuildData(PlatformBuildClassObject): except: EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute command: %s' % Command) Result = Process.communicate() - return Process.returncode, Result[0], Result[1] + return Process.returncode, Result[0].decode(encoding='utf-8', errors='ignore'), Result[1].decode(encoding='utf-8', errors='ignore') @staticmethod def IntToCString(Value, ValueSize): -- cgit v1.2.3