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>
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user