BaseTools: Refactor python except statements

Convert "except ... ," to "except ... as" to be compatible with python3.
Based on "futurize -f lib2to3.fixes.fix_except"

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:
Gary Lin
2018-06-25 18:31:25 +08:00
committed by Yonghong Zhu
parent 00eb12a2c7
commit 5b0671c1e5
46 changed files with 254 additions and 250 deletions

View File

@@ -2220,7 +2220,7 @@ class PlatformAutoGen(AutoGen):
if ToPcd.DefaultValue:
try:
ToPcd.DefaultValue = ValueExpressionEx(ToPcd.DefaultValue, ToPcd.DatumType, self._GuidDict)(True)
except BadExpression, Value:
except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.DefaultValue, Value),
File=self.MetaFile)

View File

@@ -449,7 +449,7 @@ def Main():
os.utime(Option.OutputFile, None)
else:
Dpx.Generate()
except BaseException, X:
except BaseException as X:
EdkLogger.quiet("")
if Option is not None and Option.debug is not None:
EdkLogger.quiet(traceback.format_exc())

View File

@@ -1030,7 +1030,7 @@ cleanlib:
else:
try:
Fd = open(F.Path, 'r')
except BaseException, X:
except BaseException as X:
EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F.Path + "\n\t" + str(X))
FileContent = Fd.read()

View File

@@ -254,7 +254,7 @@ class UniFileClassObject(object):
if len(Lang) != 3:
try:
FileIn = UniFileClassObject.OpenUniFile(LongFilePath(File.Path))
except UnicodeError, X:
except UnicodeError as X:
EdkLogger.error("build", FILE_READ_FAILURE, "File read failure: %s" % str(X), ExtraData=File);
except:
EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=File);
@@ -393,7 +393,7 @@ class UniFileClassObject(object):
try:
FileIn = UniFileClassObject.OpenUniFile(LongFilePath(File.Path))
except UnicodeError, X:
except UnicodeError as X:
EdkLogger.error("build", FILE_READ_FAILURE, "File read failure: %s" % str(X), ExtraData=File.Path);
except:
EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=File.Path);