BaseTools: Handle the bytes and str difference

Deal with bytes and str is different, remove the unicode()
Using utcfromtimestamp instead of fromtimestamp.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Yunhua Feng
2018-10-11 11:20:59 +08:00
committed by Yonghong Zhu
parent a09f4c91f7
commit 86e6cf98a8
33 changed files with 131 additions and 162 deletions

View File

@ -130,7 +130,14 @@ def GetDependencyList(FileStack, SearchPathList):
continue
if FileContent[0] == 0xff or FileContent[0] == 0xfe:
FileContent = unicode(FileContent, "utf-16")
FileContent = str(FileContent, "utf-16")
IncludedFileList = gIncludePattern.findall(FileContent)
else:
try:
FileContent = str(FileContent, "utf-8")
IncludedFileList = gIncludePattern.findall(FileContent)
except:
pass
IncludedFileList = gIncludePattern.findall(FileContent)
for Inc in IncludedFileList:
@ -1655,7 +1662,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):
@ -2684,7 +2691,7 @@ class DscBuildData(PlatformBuildClassObject):
Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] = {}
Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][DefaultStore] = DefaultValue
for pcd in Pcds.values():
SkuInfoObj = pcd.SkuInfoList.values()[0]
SkuInfoObj = list(pcd.SkuInfoList.values())[0]
pcdDecObject = self._DecPcds[pcd.TokenCName, pcd.TokenSpaceGuidCName]
pcd.DatumType = pcdDecObject.DatumType
# Only fix the value while no value provided in DSC file.