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:
@ -17,7 +17,7 @@
|
||||
#
|
||||
from struct import *
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import StringIO
|
||||
from io import BytesIO
|
||||
import string
|
||||
from CommonDataClass.FdfClass import RegionClassObject
|
||||
import Common.LongFilePathOs as os
|
||||
@ -127,7 +127,7 @@ class Region(RegionClassObject):
|
||||
if self.FvAddress % FvAlignValue != 0:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||
"FV (%s) is NOT %s Aligned!" % (FvObj.UiFvName, FvObj.FvAlignment))
|
||||
FvBuffer = StringIO.StringIO('')
|
||||
FvBuffer = BytesIO('')
|
||||
FvBaseAddress = '0x%X' % self.FvAddress
|
||||
BlockSize = None
|
||||
BlockNum = None
|
||||
@ -135,7 +135,8 @@ class Region(RegionClassObject):
|
||||
if Flag:
|
||||
continue
|
||||
|
||||
if FvBuffer.len > Size:
|
||||
FvBufferLen = len(FvBuffer.getvalue())
|
||||
if FvBufferLen > Size:
|
||||
FvBuffer.close()
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||
"Size of FV (%s) is larger than Region Size 0x%X specified." % (RegionData, Size))
|
||||
@ -144,8 +145,8 @@ class Region(RegionClassObject):
|
||||
#
|
||||
Buffer.write(FvBuffer.getvalue())
|
||||
FvBuffer.close()
|
||||
FvOffset = FvOffset + FvBuffer.len
|
||||
Size = Size - FvBuffer.len
|
||||
FvOffset = FvOffset + FvBufferLen
|
||||
Size = Size - FvBufferLen
|
||||
continue
|
||||
else:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (RegionData))
|
||||
|
Reference in New Issue
Block a user