summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/AutoGen
diff options
context:
space:
mode:
authorGary Lin <glin@suse.com>2018-06-25 18:31:36 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-06-27 16:33:28 +0800
commit86379ac48ba17c71d4623c57099b064b15118e21 (patch)
tree9ec107c195a28a4bdcf9b4734fa2c20b8c07ce32 /BaseTools/Source/Python/AutoGen
parent0d1f5b2b5dc3c1cf381be0a1ec8f960dc6029a93 (diff)
downloadedk2-86379ac48ba17c71d4623c57099b064b15118e21.tar.gz
edk2-86379ac48ba17c71d4623c57099b064b15118e21.tar.bz2
edk2-86379ac48ba17c71d4623c57099b064b15118e21.zip
BaseTools: Replace StringIO.StringIO with io.BytesIO
Replace StringIO.StringIO with io.BytesIO to be compatible with python3. This commit also removes "import StringIO" from those python scripts that don't really use it. Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Gary Lin <glin@suse.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/AutoGen')
-rw-r--r--BaseTools/Source/Python/AutoGen/AutoGen.py10
-rw-r--r--BaseTools/Source/Python/AutoGen/GenDepex.py4
-rw-r--r--BaseTools/Source/Python/AutoGen/GenPcdDb.py4
-rw-r--r--BaseTools/Source/Python/AutoGen/IdfClassObject.py1
-rw-r--r--BaseTools/Source/Python/AutoGen/StrGather.py4
-rw-r--r--BaseTools/Source/Python/AutoGen/UniClassObject.py6
-rw-r--r--BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py4
7 files changed, 16 insertions, 17 deletions
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index a7e1edb843..2022454004 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -25,7 +25,7 @@ import uuid
import GenC
import GenMake
import GenDepex
-from StringIO import StringIO
+from io import BytesIO
from StrGather import *
from BuildEngine import BuildRule
@@ -3437,8 +3437,8 @@ class ModuleAutoGen(AutoGen):
def _GetAutoGenFileList(self):
UniStringAutoGenC = True
IdfStringAutoGenC = True
- UniStringBinBuffer = StringIO()
- IdfGenBinBuffer = StringIO()
+ UniStringBinBuffer = BytesIO()
+ IdfGenBinBuffer = BytesIO()
if self.BuildType == 'UEFI_HII':
UniStringAutoGenC = False
IdfStringAutoGenC = False
@@ -3713,8 +3713,8 @@ class ModuleAutoGen(AutoGen):
except:
EdkLogger.error("build", FILE_OPEN_FAILURE, "File open failed for %s" % UniVfrOffsetFileName, None)
- # Use a instance of StringIO to cache data
- fStringIO = StringIO('')
+ # Use a instance of BytesIO to cache data
+ fStringIO = BytesIO('')
for Item in VfrUniOffsetList:
if (Item[0].find("Strings") != -1):
diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source/Python/AutoGen/GenDepex.py
index e89191a72b..d3b1eae181 100644
--- a/BaseTools/Source/Python/AutoGen/GenDepex.py
+++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
@@ -17,7 +17,7 @@ import Common.LongFilePathOs as os
import re
import traceback
from Common.LongFilePathSupport import OpenLongFilePath as open
-from StringIO import StringIO
+from io import BytesIO
from struct import pack
from Common.BuildToolError import *
from Common.Misc import SaveFileOnChange
@@ -345,7 +345,7 @@ class DependencyExpression:
# @retval False If file exists and is not changed.
#
def Generate(self, File=None):
- Buffer = StringIO()
+ Buffer = BytesIO()
if len(self.PostfixNotation) == 0:
return False
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index 07ba29a158..9fcd7fcc97 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -10,7 +10,7 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
-from StringIO import StringIO
+from io import BytesIO
from Common.Misc import *
from Common.StringUtils import StringToArray
from struct import pack
@@ -888,7 +888,7 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH):
DbFileName = os.path.join(Info.PlatformInfo.BuildDir, TAB_FV_DIRECTORY, Phase + "PcdDataBase.raw")
else:
DbFileName = os.path.join(Info.OutputDir, Phase + "PcdDataBase.raw")
- DbFile = StringIO()
+ DbFile = BytesIO()
DbFile.write(PcdDbBuffer)
Changed = SaveFileOnChange(DbFileName, DbFile.getvalue(), True)
def CreatePcdDataBase(PcdDBData):
diff --git a/BaseTools/Source/Python/AutoGen/IdfClassObject.py b/BaseTools/Source/Python/AutoGen/IdfClassObject.py
index e5b933c203..b656bd83e3 100644
--- a/BaseTools/Source/Python/AutoGen/IdfClassObject.py
+++ b/BaseTools/Source/Python/AutoGen/IdfClassObject.py
@@ -14,7 +14,6 @@
# Import Modules
#
import Common.EdkLogger as EdkLogger
-import StringIO
from Common.BuildToolError import *
from Common.StringUtils import GetLineNo
from Common.Misc import PathClass
diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py
index 9f70d4e5b7..0e74f3bfb7 100644
--- a/BaseTools/Source/Python/AutoGen/StrGather.py
+++ b/BaseTools/Source/Python/AutoGen/StrGather.py
@@ -18,7 +18,7 @@ import re
import Common.EdkLogger as EdkLogger
from Common.BuildToolError import *
from UniClassObject import *
-from StringIO import StringIO
+from io import BytesIO
from struct import pack, unpack
from Common.LongFilePathSupport import OpenLongFilePath as open
@@ -341,7 +341,7 @@ def CreateCFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniBinBuffer,
if Language not in UniLanguageListFiltered:
continue
- StringBuffer = StringIO()
+ StringBuffer = BytesIO()
StrStringValue = ''
ArrayLength = 0
NumberOfUseOtherLangDef = 0
diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py
index 3a931c6f27..88810f1ccc 100644
--- a/BaseTools/Source/Python/AutoGen/UniClassObject.py
+++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py
@@ -20,7 +20,7 @@ from __future__ import print_function
import Common.LongFilePathOs as os, codecs, re
import distutils.util
import Common.EdkLogger as EdkLogger
-import StringIO
+from io import BytesIO
from Common.BuildToolError import *
from Common.StringUtils import GetLineNo
from Common.Misc import PathClass
@@ -320,7 +320,7 @@ class UniFileClassObject(object):
UniFileClassObject.VerifyUcs2Data(FileIn, FileName, Encoding)
- UniFile = StringIO.StringIO(FileIn)
+ UniFile = BytesIO(FileIn)
Info = codecs.lookup(Encoding)
(Reader, Writer) = (Info.streamreader, Info.streamwriter)
return codecs.StreamReaderWriter(UniFile, Reader, Writer)
@@ -335,7 +335,7 @@ class UniFileClassObject(object):
FileDecoded = codecs.decode(FileIn, Encoding)
Ucs2Info.encode(FileDecoded)
except:
- UniFile = StringIO.StringIO(FileIn)
+ UniFile = BytesIO(FileIn)
Info = codecs.lookup(Encoding)
(Reader, Writer) = (Info.streamreader, Info.streamwriter)
File = codecs.StreamReaderWriter(UniFile, Reader, Writer)
diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
index 64d4965e96..49fbdf3246 100644
--- a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
+++ b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
@@ -17,7 +17,7 @@
import os
from Common.RangeExpression import RangeExpression
from Common.Misc import *
-from StringIO import StringIO
+from io import BytesIO
from struct import pack
from Common.DataType import *
@@ -162,7 +162,7 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object):
Buffer += b
realLength += 1
- DbFile = StringIO()
+ DbFile = BytesIO()
if Phase == 'DXE' and os.path.exists(BinFilePath):
BinFile = open(BinFilePath, "rb")
BinBuffer = BinFile.read()