diff options
author | Yunhua Feng <yunhuax.feng@intel.com> | 2018-07-27 16:02:05 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-10-13 09:50:45 +0800 |
commit | a09f4c91f785e36f0987aa3a6d7656ba51e6aeda (patch) | |
tree | 0a644e4b34f4fceb65d10465dbb6688fcddddfa5 /BaseTools/Source/Python/AutoGen | |
parent | fe3991d63552f2eb25ff728a81a6976a3b1f652b (diff) | |
download | edk2-a09f4c91f785e36f0987aa3a6d7656ba51e6aeda.tar.gz edk2-a09f4c91f785e36f0987aa3a6d7656ba51e6aeda.tar.bz2 edk2-a09f4c91f785e36f0987aa3a6d7656ba51e6aeda.zip |
BaseTools: fix the open file's read and write bugs
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>
Diffstat (limited to 'BaseTools/Source/Python/AutoGen')
-rw-r--r-- | BaseTools/Source/Python/AutoGen/GenMake.py | 12 | ||||
-rw-r--r-- | BaseTools/Source/Python/AutoGen/InfSectionParser.py | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 75b4e2247a..b168a6663d 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1031,7 +1031,7 @@ cleanlib: CurrentFileDependencyList = DepDb[F]
else:
try:
- Fd = open(F.Path, 'r')
+ Fd = open(F.Path, 'rb')
except BaseException as X:
EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F.Path + "\n\t" + str(X))
@@ -1041,8 +1041,14 @@ cleanlib: continue
if FileContent[0] == 0xff or FileContent[0] == 0xfe:
- FileContent = unicode(FileContent, "utf-16")
- IncludedFileList = gIncludePattern.findall(FileContent)
+ FileContent = str(FileContent, encoding="utf-16")
+ IncludedFileList = gIncludePattern.findall(FileContent)
+ else:
+ try:
+ FileContent = str(FileContent, encoding="utf-8")
+ IncludedFileList = gIncludePattern.findall(FileContent)
+ except:
+ continue
for Inc in IncludedFileList:
Inc = Inc.strip()
diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTools/Source/Python/AutoGen/InfSectionParser.py index d985089738..09e9af3fb4 100644 --- a/BaseTools/Source/Python/AutoGen/InfSectionParser.py +++ b/BaseTools/Source/Python/AutoGen/InfSectionParser.py @@ -34,7 +34,7 @@ class InfSectionParser(): SectionData = []
try:
- FileLinesList = open(self._FilePath, "r", 0).readlines()
+ FileLinesList = open(self._FilePath, "r").readlines()
except BaseException:
EdkLogger.error("build", AUTOGEN_ERROR, 'File %s is opened failed.' % self._FilePath)
|