BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1540
This issue in introduced by commit
d943b0c339fe3d35ffdf9f580ccb7a55915c6854
To convert bytes to string, we need to use bytes.decode()
instead of using str(bytes).
If the source file is not a txt file, ignore that file.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F.Path + "\n\t" + str(X))\r
if len(FileContent) == 0:\r
continue\r
-\r
- if FileContent[0] == 0xff or FileContent[0] == 0xfe:\r
- FileContent = FileContent.decode('utf-16')\r
- else:\r
- try:\r
- FileContent = str(FileContent)\r
- except:\r
- pass\r
+ try:\r
+ if FileContent[0] == 0xff or FileContent[0] == 0xfe:\r
+ FileContent = FileContent.decode('utf-16')\r
+ else:\r
+ FileContent = FileContent.decode()\r
+ except:\r
+ # The file is not txt file. for example .mcb file\r
+ continue\r
IncludedFileList = gIncludePattern.findall(FileContent)\r
\r
for Inc in IncludedFileList:\r
if len(FileContent) == 0:\r
continue\r
\r
- if FileContent[0] == 0xff or FileContent[0] == 0xfe:\r
- FileContent = FileContent.decode('utf-16')\r
- IncludedFileList = gIncludePattern.findall(FileContent)\r
- else:\r
- try:\r
- FileContent = str(FileContent)\r
- IncludedFileList = gIncludePattern.findall(FileContent)\r
- except:\r
- pass\r
+ try:\r
+ if FileContent[0] == 0xff or FileContent[0] == 0xfe:\r
+ FileContent = FileContent.decode('utf-16')\r
+ else:\r
+ FileContent = FileContent.decode()\r
+ except:\r
+ # The file is not txt file. for example .mcb file\r
+ continue\r
IncludedFileList = gIncludePattern.findall(FileContent)\r
\r
for Inc in IncludedFileList:\r