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

@ -115,7 +115,7 @@ class DoxygenFile(Page):
f = open(self.mFilename, 'w') f = open(self.mFilename, 'w')
f.write('\n'.join(str)) f.write('\n'.join(str))
f.close() f.close()
except IOError, e: except IOError as e:
ErrorMsg ('Fail to write file %s' % self.mFilename) ErrorMsg ('Fail to write file %s' % self.mFilename)
return False return False
@ -429,7 +429,7 @@ class DoxygenConfigFile:
f = open(path, 'w') f = open(path, 'w')
f.write(text) f.write(text)
f.close() f.close()
except IOError, e: except IOError as e:
ErrorMsg ('Fail to generate doxygen config file %s' % path) ErrorMsg ('Fail to generate doxygen config file %s' % path)
return False return False

View File

@ -1001,7 +1001,7 @@ class PackageDocumentAction(DoxygenAction):
try: try:
file = open(path, 'rb') file = open(path, 'rb')
except (IOError, OSError), msg: except (IOError, OSError) as msg:
return None return None
t = file.read() t = file.read()

View File

@ -1004,7 +1004,7 @@ class PackageDocumentAction(DoxygenAction):
try: try:
file = open(path, 'rb') file = open(path, 'rb')
except (IOError, OSError), msg: except (IOError, OSError) as msg:
return None return None
t = file.read() t = file.read()

View File

@ -90,7 +90,8 @@ def ShellCommandResults(CmdLine, Opt):
sys.stderr.flush() sys.stderr.flush()
returnValue = err_val.returncode returnValue = err_val.returncode
except IOError as (errno, strerror): except IOError as err_val:
(errno, strerror) = err_val.args
file_list.close() file_list.close()
if not Opt.silent: if not Opt.silent:
sys.stderr.write("I/O ERROR : %s : %s\n" % (str(errno), strerror)) sys.stderr.write("I/O ERROR : %s : %s\n" % (str(errno), strerror))
@ -100,7 +101,8 @@ def ShellCommandResults(CmdLine, Opt):
sys.stderr.flush() sys.stderr.flush()
returnValue = errno returnValue = errno
except OSError as (errno, strerror): except OSError as err_val:
(errno, strerror) = err_val.args
file_list.close() file_list.close()
if not Opt.silent: if not Opt.silent:
sys.stderr.write("OS ERROR : %s : %s\n" % (str(errno), strerror)) sys.stderr.write("OS ERROR : %s : %s\n" % (str(errno), strerror))
@ -210,13 +212,15 @@ def RevertCmd(Filename, Opt):
sys.stderr.write("Subprocess ERROR : %s\n" % err_val) sys.stderr.write("Subprocess ERROR : %s\n" % err_val)
sys.stderr.flush() sys.stderr.flush()
except IOError as (errno, strerror): except IOError as err_val:
(errno, strerror) = err_val.args
if not Opt.silent: if not Opt.silent:
sys.stderr.write("I/O ERROR : %d : %s\n" % (str(errno), strerror)) sys.stderr.write("I/O ERROR : %d : %s\n" % (str(errno), strerror))
sys.stderr.write("ERROR : this command failed : %s\n" % CmdLine) sys.stderr.write("ERROR : this command failed : %s\n" % CmdLine)
sys.stderr.flush() sys.stderr.flush()
except OSError as (errno, strerror): except OSError as err_val:
(errno, strerror) = err_val.args
if not Opt.silent: if not Opt.silent:
sys.stderr.write("OS ERROR : %d : %s\n" % (str(errno), strerror)) sys.stderr.write("OS ERROR : %d : %s\n" % (str(errno), strerror))
sys.stderr.write("ERROR : this command failed : %s\n" % CmdLine) sys.stderr.write("ERROR : this command failed : %s\n" % CmdLine)

View File

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

View File

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

View File

@ -1030,7 +1030,7 @@ cleanlib:
else: else:
try: try:
Fd = open(F.Path, 'r') 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)) EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F.Path + "\n\t" + str(X))
FileContent = Fd.read() FileContent = Fd.read()

View File

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

View File

@ -307,7 +307,7 @@ class ValueExpression(BaseExpression):
} }
try: try:
Val = eval(EvalStr, {}, Dict) Val = eval(EvalStr, {}, Dict)
except Exception, Excpt: except Exception as Excpt:
raise BadExpression(str(Excpt)) raise BadExpression(str(Excpt))
if Operator in {'and', 'or'}: if Operator in {'and', 'or'}:
@ -425,7 +425,7 @@ class ValueExpression(BaseExpression):
continue continue
try: try:
Val = self.Eval(Op, Val, EvalFunc()) Val = self.Eval(Op, Val, EvalFunc())
except WrnExpression, Warn: except WrnExpression as Warn:
self._WarnExcept = Warn self._WarnExcept = Warn
Val = Warn.result Val = Warn.result
return Val return Val
@ -464,7 +464,7 @@ class ValueExpression(BaseExpression):
Op += ' ' + self._Token Op += ' ' + self._Token
try: try:
Val = self.Eval(Op, Val, self._RelExpr()) Val = self.Eval(Op, Val, self._RelExpr())
except WrnExpression, Warn: except WrnExpression as Warn:
self._WarnExcept = Warn self._WarnExcept = Warn
Val = Warn.result Val = Warn.result
return Val return Val
@ -490,14 +490,14 @@ class ValueExpression(BaseExpression):
Val = self._UnaryExpr() Val = self._UnaryExpr()
try: try:
return self.Eval('not', Val) return self.Eval('not', Val)
except WrnExpression, Warn: except WrnExpression as Warn:
self._WarnExcept = Warn self._WarnExcept = Warn
return Warn.result return Warn.result
if self._IsOperator({"~"}): if self._IsOperator({"~"}):
Val = self._UnaryExpr() Val = self._UnaryExpr()
try: try:
return self.Eval('~', Val) return self.Eval('~', Val)
except WrnExpression, Warn: except WrnExpression as Warn:
self._WarnExcept = Warn self._WarnExcept = Warn
return Warn.result return Warn.result
return self._IdenExpr() return self._IdenExpr()
@ -816,9 +816,9 @@ class ValueExpressionEx(ValueExpression):
elif self.PcdType in TAB_PCD_NUMERIC_TYPES and (PcdValue.startswith("'") or \ elif self.PcdType in TAB_PCD_NUMERIC_TYPES and (PcdValue.startswith("'") or \
PcdValue.startswith('"') or PcdValue.startswith("L'") or PcdValue.startswith('L"') or PcdValue.startswith('{')): PcdValue.startswith('"') or PcdValue.startswith("L'") or PcdValue.startswith('L"') or PcdValue.startswith('{')):
raise BadExpression raise BadExpression
except WrnExpression, Value: except WrnExpression as Value:
PcdValue = Value.result PcdValue = Value.result
except BadExpression, Value: except BadExpression as Value:
if self.PcdType in TAB_PCD_NUMERIC_TYPES: if self.PcdType in TAB_PCD_NUMERIC_TYPES:
PcdValue = PcdValue.strip() PcdValue = PcdValue.strip()
if PcdValue.startswith('{') and PcdValue.endswith('}'): if PcdValue.startswith('{') and PcdValue.endswith('}'):
@ -854,7 +854,7 @@ class ValueExpressionEx(ValueExpression):
tmpValue = int(Item, 0) tmpValue = int(Item, 0)
if tmpValue > 255: if tmpValue > 255:
raise BadExpression("Byte array number %s should less than 0xFF." % Item) raise BadExpression("Byte array number %s should less than 0xFF." % Item)
except BadExpression, Value: except BadExpression as Value:
raise BadExpression(Value) raise BadExpression(Value)
except ValueError: except ValueError:
pass pass
@ -870,7 +870,7 @@ class ValueExpressionEx(ValueExpression):
else: else:
try: try:
TmpValue, Size = ParseFieldValue(PcdValue) TmpValue, Size = ParseFieldValue(PcdValue)
except BadExpression, Value: except BadExpression as Value:
raise BadExpression("Type: %s, Value: %s, %s" % (self.PcdType, PcdValue, Value)) raise BadExpression("Type: %s, Value: %s, %s" % (self.PcdType, PcdValue, Value))
if type(TmpValue) == type(''): if type(TmpValue) == type(''):
try: try:
@ -1030,8 +1030,8 @@ if __name__ == '__main__':
try: try:
print ValueExpression(input)(True) print ValueExpression(input)(True)
print ValueExpression(input)(False) print ValueExpression(input)(False)
except WrnExpression, Ex: except WrnExpression as Ex:
print Ex.result print Ex.result
print str(Ex) print str(Ex)
except Exception, Ex: except Exception as Ex:
print str(Ex) print str(Ex)

View File

@ -478,7 +478,7 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True):
Fd = open(File, "wb") Fd = open(File, "wb")
Fd.write(Content) Fd.write(Content)
Fd.close() Fd.close()
except IOError, X: except IOError as X:
EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData='IOError %s' % X) EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData='IOError %s' % X)
return True return True
@ -512,7 +512,7 @@ def DataRestore(File):
try: try:
Fd = open(File, 'rb') Fd = open(File, 'rb')
Data = cPickle.load(Fd) Data = cPickle.load(Fd)
except Exception, e: except Exception as e:
EdkLogger.verbose("Failed to load [%s]\n\t%s" % (File, str(e))) EdkLogger.verbose("Failed to load [%s]\n\t%s" % (File, str(e)))
Data = None Data = None
finally: finally:
@ -1278,7 +1278,7 @@ def ParseDevPathValue (Value):
try: try:
p = subprocess.Popen(Cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) p = subprocess.Popen(Cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
out, err = p.communicate() out, err = p.communicate()
except Exception, X: except Exception as X:
raise BadExpression("DevicePath: %s" % (str(X)) ) raise BadExpression("DevicePath: %s" % (str(X)) )
finally: finally:
subprocess._cleanup() subprocess._cleanup()
@ -1327,7 +1327,7 @@ def ParseFieldValue (Value):
Value = Value[1:-1] Value = Value[1:-1]
try: try:
Value = "'" + uuid.UUID(Value).get_bytes_le() + "'" Value = "'" + uuid.UUID(Value).get_bytes_le() + "'"
except ValueError, Message: except ValueError as Message:
raise BadExpression(Message) raise BadExpression(Message)
Value, Size = ParseFieldValue(Value) Value, Size = ParseFieldValue(Value)
return Value, 16 return Value, 16

View File

@ -422,7 +422,7 @@ class RangeExpression(BaseExpression):
Op = self._Token Op = self._Token
try: try:
Val = self.Eval(Op, Val, EvalFunc()) Val = self.Eval(Op, Val, EvalFunc())
except WrnExpression, Warn: except WrnExpression as Warn:
self._WarnExcept = Warn self._WarnExcept = Warn
Val = Warn.result Val = Warn.result
return Val return Val
@ -445,7 +445,7 @@ class RangeExpression(BaseExpression):
Op += ' ' + self._Token Op += ' ' + self._Token
try: try:
Val = self.Eval(Op, Val, self._RelExpr()) Val = self.Eval(Op, Val, self._RelExpr())
except WrnExpression, Warn: except WrnExpression as Warn:
self._WarnExcept = Warn self._WarnExcept = Warn
Val = Warn.result Val = Warn.result
return Val return Val
@ -457,7 +457,7 @@ class RangeExpression(BaseExpression):
Val = self._NeExpr() Val = self._NeExpr()
try: try:
return self.Eval(Token, Val) return self.Eval(Token, Val)
except WrnExpression, Warn: except WrnExpression as Warn:
self._WarnExcept = Warn self._WarnExcept = Warn
return Warn.result return Warn.result
return self._IdenExpr() return self._IdenExpr()

View File

@ -245,7 +245,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName):
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr= subprocess.PIPE, stderr= subprocess.PIPE,
shell=True) shell=True)
except Exception, X: except Exception as X:
EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData=str(X)) EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData=str(X))
(out, error) = PopenObject.communicate() (out, error) = PopenObject.communicate()
print out print out

View File

@ -173,7 +173,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -532,7 +532,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -809,7 +809,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -964,7 +964,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1092,7 +1092,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1162,7 +1162,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1216,7 +1216,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1263,7 +1263,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1432,7 +1432,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1465,7 +1465,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1589,7 +1589,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1636,7 +1636,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1699,7 +1699,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1742,7 +1742,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1861,7 +1861,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1921,7 +1921,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -2003,7 +2003,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -2158,7 +2158,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -2223,7 +2223,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -2275,7 +2275,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -2322,7 +2322,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -2464,7 +2464,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3056,7 +3056,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3206,7 +3206,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3462,7 +3462,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3528,7 +3528,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3617,7 +3617,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3825,7 +3825,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3881,7 +3881,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3971,7 +3971,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -4219,7 +4219,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -4570,7 +4570,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -4690,7 +4690,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -4770,7 +4770,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -4835,7 +4835,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -4933,7 +4933,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5012,7 +5012,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5103,7 +5103,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5203,7 +5203,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5355,7 +5355,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5583,7 +5583,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5644,7 +5644,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5691,7 +5691,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5789,7 +5789,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5995,7 +5995,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -6065,7 +6065,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -6100,7 +6100,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8135,7 +8135,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8170,7 +8170,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8217,7 +8217,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8285,7 +8285,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8355,7 +8355,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8415,7 +8415,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8475,7 +8475,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8535,7 +8535,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8595,7 +8595,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8669,7 +8669,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8743,7 +8743,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8817,7 +8817,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -9058,7 +9058,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -9155,7 +9155,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -9228,7 +9228,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -9301,7 +9301,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -12467,7 +12467,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -12560,7 +12560,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -14530,7 +14530,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -16251,7 +16251,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -16322,7 +16322,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -16435,7 +16435,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -16586,7 +16586,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -16703,7 +16703,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:

View File

@ -98,7 +98,7 @@ class Table(object):
SqlCommand = """drop table IF EXISTS %s""" % self.Table SqlCommand = """drop table IF EXISTS %s""" % self.Table
try: try:
self.Cur.execute(SqlCommand) self.Cur.execute(SqlCommand)
except Exception, e: except Exception as e:
print "An error occurred when Drop a table:", e.args[0] print "An error occurred when Drop a table:", e.args[0]
## Get count ## Get count

View File

@ -1183,7 +1183,7 @@ class DscParser(MetaFileParser):
try: try:
Processer[self._ItemType]() Processer[self._ItemType]()
except EvaluationException, Excpt: except EvaluationException as Excpt:
# #
# Only catch expression evaluation error here. We need to report # Only catch expression evaluation error here. We need to report
# the precise number of line on which the error occurred # the precise number of line on which the error occurred
@ -1192,7 +1192,7 @@ class DscParser(MetaFileParser):
# EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt), # EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),
# File=self._FileWithError, ExtraData=' '.join(self._ValueList), # File=self._FileWithError, ExtraData=' '.join(self._ValueList),
# Line=self._LineIndex+1) # Line=self._LineIndex+1)
except MacroException, Excpt: except MacroException as Excpt:
EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt), EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt),
File=self._FileWithError, ExtraData=' '.join(self._ValueList), File=self._FileWithError, ExtraData=' '.join(self._ValueList),
Line=self._LineIndex+1) Line=self._LineIndex+1)
@ -1305,10 +1305,10 @@ class DscParser(MetaFileParser):
Macros.update(GlobalData.gGlobalDefines) Macros.update(GlobalData.gGlobalDefines)
try: try:
Result = ValueExpression(self._ValueList[1], Macros)() Result = ValueExpression(self._ValueList[1], Macros)()
except SymbolNotFound, Exc: except SymbolNotFound as Exc:
EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueList[1]) EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueList[1])
Result = False Result = False
except WrnExpression, Excpt: except WrnExpression as Excpt:
# #
# Catch expression evaluation warning here. We need to report # Catch expression evaluation warning here. We need to report
# the precise number of line and return the evaluation result # the precise number of line and return the evaluation result
@ -1317,7 +1317,7 @@ class DscParser(MetaFileParser):
File=self._FileWithError, ExtraData=' '.join(self._ValueList), File=self._FileWithError, ExtraData=' '.join(self._ValueList),
Line=self._LineIndex+1) Line=self._LineIndex+1)
Result = Excpt.result Result = Excpt.result
except BadExpression, Exc: except BadExpression as Exc:
EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueList[1]) EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueList[1])
Result = False Result = False
@ -1437,13 +1437,13 @@ class DscParser(MetaFileParser):
PcdValue = ValueList[0] PcdValue = ValueList[0]
try: try:
ValueList[0] = ValueExpression(PcdValue, self._Macros)(True) ValueList[0] = ValueExpression(PcdValue, self._Macros)(True)
except WrnExpression, Value: except WrnExpression as Value:
ValueList[0] = Value.result ValueList[0] = Value.result
else: else:
PcdValue = ValueList[-1] PcdValue = ValueList[-1]
try: try:
ValueList[-1] = ValueExpression(PcdValue, self._Macros)(True) ValueList[-1] = ValueExpression(PcdValue, self._Macros)(True)
except WrnExpression, Value: except WrnExpression as Value:
ValueList[-1] = Value.result ValueList[-1] = Value.result
if ValueList[-1] == 'True': if ValueList[-1] == 'True':

View File

@ -214,7 +214,7 @@ def XmlParseFile(FileName):
Dom = xml.dom.minidom.parse(XmlFile) Dom = xml.dom.minidom.parse(XmlFile)
XmlFile.close() XmlFile.close()
return Dom return Dom
except Exception, X: except Exception as X:
print X print X
return "" return ""

View File

@ -2633,7 +2633,7 @@ if __name__ == '__main__':
# CollectSourceCodeDataIntoDB(sys.argv[1]) # CollectSourceCodeDataIntoDB(sys.argv[1])
try: try:
test_file = sys.argv[1] test_file = sys.argv[1]
except IndexError, v: except IndexError as v:
print "Usage: %s filename" % sys.argv[0] print "Usage: %s filename" % sys.argv[0]
sys.exit(1) sys.exit(1)
MsgList = CheckFuncHeaderDoxygenComments(test_file) MsgList = CheckFuncHeaderDoxygenComments(test_file)

View File

@ -173,7 +173,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -532,7 +532,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -809,7 +809,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -964,7 +964,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1092,7 +1092,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1162,7 +1162,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1216,7 +1216,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1263,7 +1263,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1432,7 +1432,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1465,7 +1465,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1589,7 +1589,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1636,7 +1636,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1699,7 +1699,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1742,7 +1742,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1861,7 +1861,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -1921,7 +1921,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -2003,7 +2003,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -2158,7 +2158,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -2223,7 +2223,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -2275,7 +2275,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -2322,7 +2322,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -2464,7 +2464,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3056,7 +3056,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3206,7 +3206,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3462,7 +3462,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3528,7 +3528,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3617,7 +3617,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3825,7 +3825,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3881,7 +3881,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -3971,7 +3971,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -4219,7 +4219,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -4570,7 +4570,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -4690,7 +4690,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -4770,7 +4770,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -4835,7 +4835,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -4933,7 +4933,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5012,7 +5012,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5103,7 +5103,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5203,7 +5203,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5355,7 +5355,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5583,7 +5583,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5644,7 +5644,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5691,7 +5691,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5789,7 +5789,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -5995,7 +5995,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -6065,7 +6065,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -6100,7 +6100,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8135,7 +8135,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8170,7 +8170,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8217,7 +8217,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8285,7 +8285,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8355,7 +8355,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8415,7 +8415,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8475,7 +8475,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8535,7 +8535,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8595,7 +8595,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8669,7 +8669,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8743,7 +8743,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -8817,7 +8817,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -9058,7 +9058,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -9155,7 +9155,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -9228,7 +9228,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -9301,7 +9301,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -12467,7 +12467,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -12560,7 +12560,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -14530,7 +14530,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -16251,7 +16251,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -16322,7 +16322,7 @@ class CParser(Parser):
retval.stop = self.input.LT(-1) retval.stop = self.input.LT(-1)
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -16435,7 +16435,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -16586,7 +16586,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:
@ -16703,7 +16703,7 @@ class CParser(Parser):
except RecognitionException, re: except RecognitionException as re:
self.reportError(re) self.reportError(re)
self.recover(self.input, re) self.recover(self.input, re)
finally: finally:

View File

@ -921,7 +921,7 @@ class FdfParser:
return ValueExpression(Expression, MacroPcdDict)(True) return ValueExpression(Expression, MacroPcdDict)(True)
else: else:
return ValueExpression(Expression, MacroPcdDict)() return ValueExpression(Expression, MacroPcdDict)()
except WrnExpression, Excpt: except WrnExpression as Excpt:
# #
# Catch expression evaluation warning here. We need to report # Catch expression evaluation warning here. We need to report
# the precise number of line and return the evaluation result # the precise number of line and return the evaluation result
@ -930,7 +930,7 @@ class FdfParser:
File=self.FileName, ExtraData=self.__CurrentLine(), File=self.FileName, ExtraData=self.__CurrentLine(),
Line=Line) Line=Line)
return Excpt.result return Excpt.result
except Exception, Excpt: except Exception as Excpt:
if hasattr(Excpt, 'Pcd'): if hasattr(Excpt, 'Pcd'):
if Excpt.Pcd in GlobalData.gPlatformOtherPcds: if Excpt.Pcd in GlobalData.gPlatformOtherPcds:
Info = GlobalData.gPlatformOtherPcds[Excpt.Pcd] Info = GlobalData.gPlatformOtherPcds[Excpt.Pcd]
@ -1368,7 +1368,7 @@ class FdfParser:
while self.__GetFd() or self.__GetFv() or self.__GetFmp() or self.__GetCapsule() or self.__GetVtf() or self.__GetRule() or self.__GetOptionRom(): while self.__GetFd() or self.__GetFv() or self.__GetFmp() or self.__GetCapsule() or self.__GetVtf() or self.__GetRule() or self.__GetOptionRom():
pass pass
except Warning, X: except Warning as X:
self.__UndoToken() self.__UndoToken()
#'\n\tGot Token: \"%s\" from File %s\n' % (self.__Token, FileLineTuple[0]) + \ #'\n\tGot Token: \"%s\" from File %s\n' % (self.__Token, FileLineTuple[0]) + \
# At this point, the closest parent would be the included file itself # At this point, the closest parent would be the included file itself
@ -4776,7 +4776,7 @@ if __name__ == "__main__":
import sys import sys
try: try:
test_file = sys.argv[1] test_file = sys.argv[1]
except IndexError, v: except IndexError as v:
print "Usage: %s filename" % sys.argv[0] print "Usage: %s filename" % sys.argv[0]
sys.exit(1) sys.exit(1)
@ -4784,7 +4784,7 @@ if __name__ == "__main__":
try: try:
parser.ParseFile() parser.ParseFile()
parser.CycleReferenceCheck() parser.CycleReferenceCheck()
except Warning, X: except Warning as X:
print str(X) print str(X)
else: else:
print "Success!" print "Success!"

View File

@ -335,10 +335,10 @@ def main():
"""Display FV space info.""" """Display FV space info."""
GenFds.DisplayFvSpaceInfo(FdfParserObj) GenFds.DisplayFvSpaceInfo(FdfParserObj)
except FdfParser.Warning, X: except FdfParser.Warning as X:
EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError=False) EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError=False)
ReturnCode = FORMAT_INVALID ReturnCode = FORMAT_INVALID
except FatalError, X: except FatalError as X:
if Options.debug is not None: if Options.debug is not None:
import traceback import traceback
EdkLogger.quiet(traceback.format_exc()) EdkLogger.quiet(traceback.format_exc())

View File

@ -721,7 +721,7 @@ class GenFdsGlobalVariable:
try: try:
PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
except Exception, X: except Exception as X:
EdkLogger.error("GenFds", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0])) EdkLogger.error("GenFds", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))
(out, error) = PopenObject.communicate() (out, error) = PopenObject.communicate()

View File

@ -253,7 +253,7 @@ if __name__ == '__main__':
FileHandle.RWFile('#', '=', 0) FileHandle.RWFile('#', '=', 0)
else: else:
FileHandle.RWFile('#', '=', 1) FileHandle.RWFile('#', '=', 1)
except Exception, e: except Exception as e:
last_type, last_value, last_tb = sys.exc_info() last_type, last_value, last_tb = sys.exc_info()
traceback.print_exception(last_type, last_value, last_tb) traceback.print_exception(last_type, last_value, last_tb)

View File

@ -668,7 +668,7 @@ def Main():
EdkLogger.SetLevel(CommandOptions.LogLevel + 1) EdkLogger.SetLevel(CommandOptions.LogLevel + 1)
else: else:
EdkLogger.SetLevel(CommandOptions.LogLevel) EdkLogger.SetLevel(CommandOptions.LogLevel)
except FatalError, X: except FatalError as X:
return 1 return 1
try: try:
@ -688,7 +688,7 @@ def Main():
if CommandOptions.OutputFile is None: if CommandOptions.OutputFile is None:
CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii' CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii'
TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, CommandOptions.ConvertHex, CommandOptions.TrimLong) TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, CommandOptions.ConvertHex, CommandOptions.TrimLong)
except FatalError, X: except FatalError as X:
import platform import platform
import traceback import traceback
if CommandOptions is not None and CommandOptions.LogLevel <= EdkLogger.DEBUG_9: if CommandOptions is not None and CommandOptions.LogLevel <= EdkLogger.DEBUG_9:

View File

@ -394,7 +394,7 @@ def VerifyRemoveModuleDep(Path, DpPackagePathList):
return False return False
else: else:
return True return True
except FatalError, ErrCode: except FatalError as ErrCode:
if ErrCode.message == EDK1_INF_ERROR: if ErrCode.message == EDK1_INF_ERROR:
Logger.Warn("UPT", Logger.Warn("UPT",
ST.WRN_EDK1_INF_FOUND%Path) ST.WRN_EDK1_INF_FOUND%Path)
@ -446,7 +446,7 @@ def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList):
return False return False
else: else:
return True return True
except FatalError, ErrCode: except FatalError as ErrCode:
if ErrCode.message == EDK1_INF_ERROR: if ErrCode.message == EDK1_INF_ERROR:
Logger.Warn("UPT", Logger.Warn("UPT",
ST.WRN_EDK1_INF_FOUND%Path) ST.WRN_EDK1_INF_FOUND%Path)

View File

@ -155,7 +155,7 @@ class DistributionPackageClass(object):
ModuleObj.GetName(), \ ModuleObj.GetName(), \
ModuleObj.GetCombinePath())] = ModuleObj ModuleObj.GetCombinePath())] = ModuleObj
PackageObj.SetModuleDict(ModuleDict) PackageObj.SetModuleDict(ModuleDict)
except FatalError, ErrCode: except FatalError as ErrCode:
if ErrCode.message == EDK1_INF_ERROR: if ErrCode.message == EDK1_INF_ERROR:
Logger.Warn("UPT", Logger.Warn("UPT",
ST.WRN_EDK1_INF_FOUND%Filename) ST.WRN_EDK1_INF_FOUND%Filename)
@ -181,7 +181,7 @@ class DistributionPackageClass(object):
ModuleObj.GetName(), ModuleObj.GetName(),
ModuleObj.GetCombinePath()) ModuleObj.GetCombinePath())
self.ModuleSurfaceArea[ModuleKey] = ModuleObj self.ModuleSurfaceArea[ModuleKey] = ModuleObj
except FatalError, ErrCode: except FatalError as ErrCode:
if ErrCode.message == EDK1_INF_ERROR: if ErrCode.message == EDK1_INF_ERROR:
Logger.Error("UPT", Logger.Error("UPT",
EDK1_INF_ERROR, EDK1_INF_ERROR,

View File

@ -230,7 +230,7 @@ class IpiDatabase(object):
self._AddDp(DpObj.Header.GetGuid(), DpObj.Header.GetVersion(), \ self._AddDp(DpObj.Header.GetGuid(), DpObj.Header.GetVersion(), \
NewDpPkgFileName, DpPkgFileName, RePackage) NewDpPkgFileName, DpPkgFileName, RePackage)
except sqlite3.IntegrityError, DetailMsg: except sqlite3.IntegrityError as DetailMsg:
Logger.Error("UPT", Logger.Error("UPT",
UPT_DB_UPDATE_ERROR, UPT_DB_UPDATE_ERROR,
ST.ERR_UPT_DB_UPDATE_ERROR, ST.ERR_UPT_DB_UPDATE_ERROR,

View File

@ -51,7 +51,7 @@ class PackageFile:
self._Files = {} self._Files = {}
for Filename in self._ZipFile.namelist(): for Filename in self._ZipFile.namelist():
self._Files[os.path.normpath(Filename)] = Filename self._Files[os.path.normpath(Filename)] = Filename
except BaseException, Xstr: except BaseException as Xstr:
Logger.Error("PackagingTool", FILE_OPEN_FAILURE, Logger.Error("PackagingTool", FILE_OPEN_FAILURE,
ExtraData="%s (%s)" % (FileName, str(Xstr))) ExtraData="%s (%s)" % (FileName, str(Xstr)))
@ -106,7 +106,7 @@ class PackageFile:
ExtraData="[%s] in %s" % (Which, self._FileName)) ExtraData="[%s] in %s" % (Which, self._FileName))
try: try:
FileContent = self._ZipFile.read(self._Files[Which]) FileContent = self._ZipFile.read(self._Files[Which])
except BaseException, Xstr: except BaseException as Xstr:
Logger.Error("PackagingTool", FILE_DECOMPRESS_FAILURE, Logger.Error("PackagingTool", FILE_DECOMPRESS_FAILURE,
ExtraData="[%s] in %s (%s)" % (Which, \ ExtraData="[%s] in %s (%s)" % (Which, \
self._FileName, \ self._FileName, \
@ -119,14 +119,14 @@ class PackageFile:
return return
else: else:
ToFile = __FileHookOpen__(ToDest, 'wb') ToFile = __FileHookOpen__(ToDest, 'wb')
except BaseException, Xstr: except BaseException as Xstr:
Logger.Error("PackagingTool", FILE_OPEN_FAILURE, Logger.Error("PackagingTool", FILE_OPEN_FAILURE,
ExtraData="%s (%s)" % (ToDest, str(Xstr))) ExtraData="%s (%s)" % (ToDest, str(Xstr)))
try: try:
ToFile.write(FileContent) ToFile.write(FileContent)
ToFile.close() ToFile.close()
except BaseException, Xstr: except BaseException as Xstr:
Logger.Error("PackagingTool", FILE_WRITE_FAILURE, Logger.Error("PackagingTool", FILE_WRITE_FAILURE,
ExtraData="%s (%s)" % (ToDest, str(Xstr))) ExtraData="%s (%s)" % (ToDest, str(Xstr)))
@ -228,7 +228,7 @@ class PackageFile:
return return
Logger.Info("packing ..." + File) Logger.Info("packing ..." + File)
self._ZipFile.write(File, ArcName) self._ZipFile.write(File, ArcName)
except BaseException, Xstr: except BaseException as Xstr:
Logger.Error("PackagingTool", FILE_COMPRESS_FAILURE, Logger.Error("PackagingTool", FILE_COMPRESS_FAILURE,
ExtraData="%s (%s)" % (File, str(Xstr))) ExtraData="%s (%s)" % (File, str(Xstr)))
@ -242,7 +242,7 @@ class PackageFile:
if os.path.splitext(ArcName)[1].lower() == '.pkg': if os.path.splitext(ArcName)[1].lower() == '.pkg':
Data = Data.encode('utf_8') Data = Data.encode('utf_8')
self._ZipFile.writestr(ArcName, Data) self._ZipFile.writestr(ArcName, Data)
except BaseException, Xstr: except BaseException as Xstr:
Logger.Error("PackagingTool", FILE_COMPRESS_FAILURE, Logger.Error("PackagingTool", FILE_COMPRESS_FAILURE,
ExtraData="%s (%s)" % (ArcName, str(Xstr))) ExtraData="%s (%s)" % (ArcName, str(Xstr)))

View File

@ -537,7 +537,7 @@ def Main(Options = None):
Options, Dep, WorkspaceDir, DataBase) Options, Dep, WorkspaceDir, DataBase)
ReturnCode = 0 ReturnCode = 0
except FatalError, XExcept: except FatalError as XExcept:
ReturnCode = XExcept.args[0] ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9: if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc()) Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())

View File

@ -92,7 +92,7 @@ def Main(Options = None):
DataBase = GlobalData.gDB DataBase = GlobalData.gDB
InventoryDistInstalled(DataBase) InventoryDistInstalled(DataBase)
ReturnCode = 0 ReturnCode = 0
except FatalError, XExcept: except FatalError as XExcept:
ReturnCode = XExcept.args[0] ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9: if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc()) Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())

View File

@ -217,7 +217,7 @@ def ParsePcdErrorCode (Value = None, ContainerFile = None, LineNum = None):
# To delete the tailing 'L' # To delete the tailing 'L'
# #
return hex(ErrorCode)[:-1] return hex(ErrorCode)[:-1]
except ValueError, XStr: except ValueError as XStr:
if XStr: if XStr:
pass pass
Logger.Error('Parser', Logger.Error('Parser',

View File

@ -297,7 +297,7 @@ class _LogicalExpressionParser(_ExprBase):
try: try:
if self.LogicalExpression() not in [self.ARITH, self.LOGICAL, self.REALLOGICAL, self.STRINGITEM]: if self.LogicalExpression() not in [self.ARITH, self.LOGICAL, self.REALLOGICAL, self.STRINGITEM]:
return False, ST.ERR_EXPR_LOGICAL % self.Token return False, ST.ERR_EXPR_LOGICAL % self.Token
except _ExprError, XExcept: except _ExprError as XExcept:
return False, XExcept.Error return False, XExcept.Error
self.SkipWhitespace() self.SkipWhitespace()
if self.Index != self.Len: if self.Index != self.Len:
@ -327,7 +327,7 @@ class _ValidRangeExpressionParser(_ExprBase):
try: try:
if self.RangeExpression() not in [self.HEX, self.INT]: if self.RangeExpression() not in [self.HEX, self.INT]:
return False, ST.ERR_EXPR_RANGE % self.Token return False, ST.ERR_EXPR_RANGE % self.Token
except _ExprError, XExcept: except _ExprError as XExcept:
return False, XExcept.Error return False, XExcept.Error
self.SkipWhitespace() self.SkipWhitespace()
@ -423,7 +423,7 @@ class _ValidListExpressionParser(_ExprBase):
try: try:
if self.ListExpression() not in [self.NUM]: if self.ListExpression() not in [self.NUM]:
return False, ST.ERR_EXPR_LIST % self.Token return False, ST.ERR_EXPR_LIST % self.Token
except _ExprError, XExcept: except _ExprError as XExcept:
return False, XExcept.Error return False, XExcept.Error
self.SkipWhitespace() self.SkipWhitespace()
@ -457,7 +457,7 @@ class _StringTestParser(_ExprBase):
return False, ST.ERR_EXPR_EMPTY return False, ST.ERR_EXPR_EMPTY
try: try:
self.StringTest() self.StringTest()
except _ExprError, XExcept: except _ExprError as XExcept:
return False, XExcept.Error return False, XExcept.Error
return True, '' return True, ''

View File

@ -327,9 +327,9 @@ class UniFileClassObject(object):
if len(Lang) != 3: if len(Lang) != 3:
try: try:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_8').readlines() FileIn = codecs.open(File.Path, mode='rb', encoding='utf_8').readlines()
except UnicodeError, Xstr: except UnicodeError as Xstr:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16').readlines() FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16').readlines()
except UnicodeError, Xstr: except UnicodeError as Xstr:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16_le').readlines() FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16_le').readlines()
except: except:
EdkLogger.Error("Unicode File Parser", EdkLogger.Error("Unicode File Parser",
@ -436,7 +436,7 @@ class UniFileClassObject(object):
try: try:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_8').readlines() FileIn = codecs.open(File.Path, mode='rb', encoding='utf_8').readlines()
except UnicodeError, Xstr: except UnicodeError as Xstr:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16').readlines() FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16').readlines()
except UnicodeError: except UnicodeError:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16_le').readlines() FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16_le').readlines()
@ -1042,7 +1042,7 @@ class UniFileClassObject(object):
ExtraData=FilaPath) ExtraData=FilaPath)
try: try:
FileIn = codecs.open(FilaPath, mode='rb', encoding='utf_8').readlines() FileIn = codecs.open(FilaPath, mode='rb', encoding='utf_8').readlines()
except UnicodeError, Xstr: except UnicodeError as Xstr:
FileIn = codecs.open(FilaPath, mode='rb', encoding='utf_16').readlines() FileIn = codecs.open(FilaPath, mode='rb', encoding='utf_16').readlines()
except UnicodeError: except UnicodeError:
FileIn = codecs.open(FilaPath, mode='rb', encoding='utf_16_le').readlines() FileIn = codecs.open(FilaPath, mode='rb', encoding='utf_16_le').readlines()

View File

@ -224,6 +224,6 @@ def XmlParseFile(FileName):
Dom = xml.dom.minidom.parse(XmlFile) Dom = xml.dom.minidom.parse(XmlFile)
XmlFile.close() XmlFile.close()
return Dom return Dom
except BaseException, XExcept: except BaseException as XExcept:
XmlFile.close() XmlFile.close()
Logger.Error('\nUPT', PARSER_ERROR, XExcept, File=FileName, RaiseError=True) Logger.Error('\nUPT', PARSER_ERROR, XExcept, File=FileName, RaiseError=True)

View File

@ -213,7 +213,7 @@ def Main(Options = None):
Logger.Quiet(ST.MSG_FINISH) Logger.Quiet(ST.MSG_FINISH)
ReturnCode = 0 ReturnCode = 0
except FatalError, XExcept: except FatalError as XExcept:
ReturnCode = XExcept.args[0] ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9: if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % \ Logger.Quiet(ST.MSG_PYTHON_ON % \

View File

@ -71,7 +71,7 @@ def Main(Options = None):
InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, WorkspaceDir, DataBase) InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, WorkspaceDir, DataBase)
ReturnCode = 0 ReturnCode = 0
except FatalError, XExcept: except FatalError as XExcept:
ReturnCode = XExcept.args[0] ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9: if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(),

View File

@ -157,7 +157,7 @@ def Main(Options = None):
ReturnCode = 0 ReturnCode = 0
except FatalError, XExcept: except FatalError as XExcept:
ReturnCode = XExcept.args[0] ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9: if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + \ Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + \

View File

@ -68,12 +68,12 @@ def Main(Options=None):
else: else:
Logger.Quiet(ST.MSG_TEST_INSTALL_FAIL) Logger.Quiet(ST.MSG_TEST_INSTALL_FAIL)
except TE.FatalError, XExcept: except TE.FatalError as XExcept:
ReturnCode = XExcept.args[0] ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9: if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc()) Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
except Exception, x: except Exception as x:
ReturnCode = TE.CODE_ERROR ReturnCode = TE.CODE_ERROR
Logger.Error( Logger.Error(
"\nTestInstallPkg", "\nTestInstallPkg",

View File

@ -179,7 +179,7 @@ def Main():
try: try:
GlobalData.gWORKSPACE, GlobalData.gPACKAGE_PATH = GetWorkspace() GlobalData.gWORKSPACE, GlobalData.gPACKAGE_PATH = GetWorkspace()
except FatalError, XExcept: except FatalError as XExcept:
if Logger.GetLevel() <= Logger.DEBUG_9: if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc()) Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
return XExcept.args[0] return XExcept.args[0]
@ -294,7 +294,7 @@ def Main():
return OPTION_MISSING return OPTION_MISSING
ReturnCode = RunModule(Opt) ReturnCode = RunModule(Opt)
except FatalError, XExcept: except FatalError as XExcept:
ReturnCode = XExcept.args[0] ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9: if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + \ Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + \

View File

@ -120,7 +120,7 @@ def GetDependencyList(FileStack,SearchPathList):
try: try:
Fd = open(F, 'r') Fd = open(F, 'r')
FileContent = Fd.read() FileContent = Fd.read()
except BaseException, X: except BaseException as X:
EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F + "\n\t" + str(X)) EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F + "\n\t" + str(X))
finally: finally:
if "Fd" in dir(locals()): if "Fd" in dir(locals()):
@ -887,11 +887,11 @@ class DscBuildData(PlatformBuildClassObject):
DatumType = self._DecPcds[PcdCName, TokenSpaceGuid].DatumType DatumType = self._DecPcds[PcdCName, TokenSpaceGuid].DatumType
try: try:
ValueList[Index] = ValueExpressionEx(ValueList[Index], DatumType, self._GuidDict)(True) ValueList[Index] = ValueExpressionEx(ValueList[Index], DatumType, self._GuidDict)(True)
except BadExpression, Value: except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=LineNo, EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=LineNo,
ExtraData="PCD [%s.%s] Value \"%s\" " % ( ExtraData="PCD [%s.%s] Value \"%s\" " % (
TokenSpaceGuid, PcdCName, ValueList[Index])) TokenSpaceGuid, PcdCName, ValueList[Index]))
except EvaluationException, Excpt: except EvaluationException as Excpt:
if hasattr(Excpt, 'Pcd'): if hasattr(Excpt, 'Pcd'):
if Excpt.Pcd in GlobalData.gPlatformOtherPcds: if Excpt.Pcd in GlobalData.gPlatformOtherPcds:
EdkLogger.error('Parser', FORMAT_INVALID, "Cannot use this PCD (%s) in an expression as" EdkLogger.error('Parser', FORMAT_INVALID, "Cannot use this PCD (%s) in an expression as"
@ -1059,7 +1059,7 @@ class DscBuildData(PlatformBuildClassObject):
return PcdValue return PcdValue
try: try:
PcdValue = ValueExpressionEx(PcdValue[1:], PcdDatumType, GuidDict)(True) PcdValue = ValueExpressionEx(PcdValue[1:], PcdDatumType, GuidDict)(True)
except BadExpression, Value: except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %
(TokenSpaceGuidCName, TokenCName, PcdValue, Value)) (TokenSpaceGuidCName, TokenCName, PcdValue, Value))
elif PcdValue.startswith("L'") or PcdValue.startswith("'"): elif PcdValue.startswith("L'") or PcdValue.startswith("'"):
@ -1070,7 +1070,7 @@ class DscBuildData(PlatformBuildClassObject):
return PcdValue return PcdValue
try: try:
PcdValue = ValueExpressionEx(PcdValue, PcdDatumType, GuidDict)(True) PcdValue = ValueExpressionEx(PcdValue, PcdDatumType, GuidDict)(True)
except BadExpression, Value: except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %
(TokenSpaceGuidCName, TokenCName, PcdValue, Value)) (TokenSpaceGuidCName, TokenCName, PcdValue, Value))
elif PcdValue.startswith('L'): elif PcdValue.startswith('L'):
@ -1082,7 +1082,7 @@ class DscBuildData(PlatformBuildClassObject):
return PcdValue return PcdValue
try: try:
PcdValue = ValueExpressionEx(PcdValue, PcdDatumType, GuidDict)(True) PcdValue = ValueExpressionEx(PcdValue, PcdDatumType, GuidDict)(True)
except BadExpression, Value: except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %
(TokenSpaceGuidCName, TokenCName, PcdValue, Value)) (TokenSpaceGuidCName, TokenCName, PcdValue, Value))
else: else:
@ -1109,7 +1109,7 @@ class DscBuildData(PlatformBuildClassObject):
return PcdValue return PcdValue
try: try:
PcdValue = ValueExpressionEx(PcdValue, PcdDatumType, GuidDict)(True) PcdValue = ValueExpressionEx(PcdValue, PcdDatumType, GuidDict)(True)
except BadExpression, Value: except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %
(TokenSpaceGuidCName, TokenCName, PcdValue, Value)) (TokenSpaceGuidCName, TokenCName, PcdValue, Value))
return PcdValue return PcdValue

View File

@ -1121,7 +1121,7 @@ class InfBuildData(ModuleBuildClassObject):
else: else:
try: try:
Pcd.DefaultValue = ValueExpressionEx(Pcd.DefaultValue, Pcd.DatumType, _GuidDict)(True) Pcd.DefaultValue = ValueExpressionEx(Pcd.DefaultValue, Pcd.DatumType, _GuidDict)(True)
except BadExpression, Value: except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %(TokenSpaceGuid, PcdRealName, Pcd.DefaultValue, Value), EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %(TokenSpaceGuid, PcdRealName, Pcd.DefaultValue, Value),
File=self.MetaFile, Line=LineNo) File=self.MetaFile, Line=LineNo)
break break

View File

@ -1341,7 +1341,7 @@ class DscParser(MetaFileParser):
self._InSubsection = False self._InSubsection = False
try: try:
Processer[self._ItemType]() Processer[self._ItemType]()
except EvaluationException, Excpt: except EvaluationException as Excpt:
# #
# Only catch expression evaluation error here. We need to report # Only catch expression evaluation error here. We need to report
# the precise number of line on which the error occurred # the precise number of line on which the error occurred
@ -1363,7 +1363,7 @@ class DscParser(MetaFileParser):
EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt), EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),
File=self._FileWithError, ExtraData=' '.join(self._ValueList), File=self._FileWithError, ExtraData=' '.join(self._ValueList),
Line=self._LineIndex + 1) Line=self._LineIndex + 1)
except MacroException, Excpt: except MacroException as Excpt:
EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt), EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt),
File=self._FileWithError, ExtraData=' '.join(self._ValueList), File=self._FileWithError, ExtraData=' '.join(self._ValueList),
Line=self._LineIndex + 1) Line=self._LineIndex + 1)
@ -1465,10 +1465,10 @@ class DscParser(MetaFileParser):
Macros.update(GlobalData.gGlobalDefines) Macros.update(GlobalData.gGlobalDefines)
try: try:
Result = ValueExpression(self._ValueList[1], Macros)() Result = ValueExpression(self._ValueList[1], Macros)()
except SymbolNotFound, Exc: except SymbolNotFound as Exc:
EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueList[1]) EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueList[1])
Result = False Result = False
except WrnExpression, Excpt: except WrnExpression as Excpt:
# #
# Catch expression evaluation warning here. We need to report # Catch expression evaluation warning here. We need to report
# the precise number of line and return the evaluation result # the precise number of line and return the evaluation result
@ -1614,7 +1614,7 @@ class DscParser(MetaFileParser):
if PcdValue and "." not in self._ValueList[0]: if PcdValue and "." not in self._ValueList[0]:
try: try:
ValList[Index] = ValueExpression(PcdValue, self._Macros)(True) ValList[Index] = ValueExpression(PcdValue, self._Macros)(True)
except WrnExpression, Value: except WrnExpression as Value:
ValList[Index] = Value.result ValList[Index] = Value.result
except: except:
pass pass
@ -2019,7 +2019,7 @@ class DecParser(MetaFileParser):
try: try:
self._GuidDict.update(self._AllPcdDict) self._GuidDict.update(self._AllPcdDict)
ValueList[0] = ValueExpressionEx(ValueList[0], ValueList[1], self._GuidDict)(True) ValueList[0] = ValueExpressionEx(ValueList[0], ValueList[1], self._GuidDict)(True)
except BadExpression, Value: except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, Value, ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) EdkLogger.error('Parser', FORMAT_INVALID, Value, ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
# check format of default value against the datum type # check format of default value against the datum type
IsValid, Cause = CheckPcdDatum(ValueList[1], ValueList[0]) IsValid, Cause = CheckPcdDatum(ValueList[1], ValueList[0])

View File

@ -63,7 +63,7 @@ class MetaFileTable(Table):
# update the timestamp in database # update the timestamp in database
self._FileIndexTable.SetFileTimeStamp(self.IdBase, TimeStamp) self._FileIndexTable.SetFileTimeStamp(self.IdBase, TimeStamp)
return False return False
except Exception, Exc: except Exception as Exc:
EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc)) EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc))
return False return False
return True return True
@ -250,7 +250,7 @@ class PackageTable(MetaFileTable):
if comment.startswith("@Expression"): if comment.startswith("@Expression"):
comment = comment.replace("@Expression", "", 1) comment = comment.replace("@Expression", "", 1)
expressions.append(comment.split("|")[1].strip()) expressions.append(comment.split("|")[1].strip())
except Exception, Exc: except Exception as Exc:
ValidType = "" ValidType = ""
if oricomment.startswith("@ValidRange"): if oricomment.startswith("@ValidRange"):
ValidType = "@ValidRange" ValidType = "@ValidRange"

View File

@ -649,7 +649,7 @@ class ModuleReport(object):
cmd = ["GenFw", "--rebase", str(0), "-o", Tempfile, DefaultEFIfile] cmd = ["GenFw", "--rebase", str(0), "-o", Tempfile, DefaultEFIfile]
try: try:
PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
except Exception, X: except Exception as X:
EdkLogger.error("GenFw", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0])) EdkLogger.error("GenFw", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))
EndOfProcedure = threading.Event() EndOfProcedure = threading.Event()
EndOfProcedure.clear() EndOfProcedure.clear()
@ -962,7 +962,7 @@ class PcdReport(object):
if DscDefaultValue != DscDefaultValBak: if DscDefaultValue != DscDefaultValBak:
try: try:
DscDefaultValue = ValueExpressionEx(DscDefaultValue, Pcd.DatumType, self._GuidDict)(True) DscDefaultValue = ValueExpressionEx(DscDefaultValue, Pcd.DatumType, self._GuidDict)(True)
except BadExpression, DscDefaultValue: except BadExpression as DscDefaultValue:
EdkLogger.error('BuildReport', FORMAT_INVALID, "PCD Value: %s, Type: %s" %(DscDefaultValue, Pcd.DatumType)) EdkLogger.error('BuildReport', FORMAT_INVALID, "PCD Value: %s, Type: %s" %(DscDefaultValue, Pcd.DatumType))
InfDefaultValue = None InfDefaultValue = None

View File

@ -548,7 +548,7 @@ class BuildTask:
EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".join(Th.getName() for Th in threading.enumerate())) EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".join(Th.getName() for Th in threading.enumerate()))
# avoid tense loop # avoid tense loop
time.sleep(0.1) time.sleep(0.1)
except BaseException, X: except BaseException as X:
# #
# TRICK: hide the output of threads left runing, so that the user can # TRICK: hide the output of threads left runing, so that the user can
# catch the error message easily # catch the error message easily
@ -1324,7 +1324,7 @@ class Build():
try: try:
#os.rmdir(AutoGenObject.BuildDir) #os.rmdir(AutoGenObject.BuildDir)
RemoveDirectory(AutoGenObject.BuildDir, True) RemoveDirectory(AutoGenObject.BuildDir, True)
except WindowsError, X: except WindowsError as X:
EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=str(X)) EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=str(X))
return True return True
@ -1414,7 +1414,7 @@ class Build():
try: try:
#os.rmdir(AutoGenObject.BuildDir) #os.rmdir(AutoGenObject.BuildDir)
RemoveDirectory(AutoGenObject.BuildDir, True) RemoveDirectory(AutoGenObject.BuildDir, True)
except WindowsError, X: except WindowsError as X:
EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=str(X)) EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=str(X))
return True return True
@ -2500,14 +2500,14 @@ def Main():
# All job done, no error found and no exception raised # All job done, no error found and no exception raised
# #
BuildError = False BuildError = False
except FatalError, X: except FatalError as X:
if MyBuild is not None: if MyBuild is not None:
# for multi-thread build exits safely # for multi-thread build exits safely
MyBuild.Relinquish() MyBuild.Relinquish()
if Option is not None and Option.debug is not None: if Option is not None and Option.debug is not None:
EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())
ReturnCode = X.args[0] ReturnCode = X.args[0]
except Warning, X: except Warning as X:
# error from Fdf parser # error from Fdf parser
if MyBuild is not None: if MyBuild is not None:
# for multi-thread build exits safely # for multi-thread build exits safely

View File

@ -29,7 +29,7 @@ class Tests(TestTools.BaseToolsTest):
def SingleFileTest(self, filename): def SingleFileTest(self, filename):
try: try:
py_compile.compile(filename, doraise=True) py_compile.compile(filename, doraise=True)
except Exception, e: except Exception as e:
self.fail('syntax error: %s, Error is %s' % (filename, str(e))) self.fail('syntax error: %s, Error is %s' % (filename, str(e)))
def MakePythonSyntaxCheckTests(): def MakePythonSyntaxCheckTests():

View File

@ -337,7 +337,7 @@ class SourceFiles:
print '[KeyboardInterrupt]' print '[KeyboardInterrupt]'
return False return False
except Exception, e: except Exception as e:
print e print e
if not completed: return False if not completed: return False