python: Make exception handling Python 3 safe
Change-Id: I9c2cdfad20deb1ddfa224320cf93f2105d126652 Reviewed-on: https://gem5-review.googlesource.com/c/15980 Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
This commit is contained in:
@@ -128,7 +128,7 @@ def compareVersions(v1, v2):
|
||||
elif isinstance(v, str):
|
||||
return map(lambda x: int(re.match('\d+', x).group()), v.split('.'))
|
||||
else:
|
||||
raise TypeError
|
||||
raise TypeError()
|
||||
|
||||
v1 = make_version_list(v1)
|
||||
v2 = make_version_list(v2)
|
||||
@@ -194,7 +194,7 @@ def readCommand(cmd, **kwargs):
|
||||
kwargs.setdefault('close_fds', True)
|
||||
try:
|
||||
subp = Popen(cmd, **kwargs)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if no_exception:
|
||||
return exception
|
||||
raise
|
||||
@@ -206,7 +206,7 @@ def makeDir(path):
|
||||
ensure that it is a directory"""
|
||||
if os.path.exists(path):
|
||||
if not os.path.isdir(path):
|
||||
raise AttributeError, "%s exists but is not directory" % path
|
||||
raise AttributeError("%s exists but is not directory" % path)
|
||||
else:
|
||||
os.mkdir(path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user