diff options
author | Andreas Sandberg <andreas.sandberg@arm.com> | 2019-01-25 11:32:25 +0000 |
---|---|---|
committer | Andreas Sandberg <andreas.sandberg@arm.com> | 2019-02-12 09:38:12 +0000 |
commit | fa21127a646b8d2a61fe412728762250ca38ecd2 (patch) | |
tree | 8f0c21351c0e7c7e30b1c03a81c3d4f122f566c5 /src/python/m5/util/jobfile.py | |
parent | 6ba4545b1f9553e68e992305c92cf46246a79dae (diff) | |
download | gem5-fa21127a646b8d2a61fe412728762250ca38ecd2.tar.xz |
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>
Diffstat (limited to 'src/python/m5/util/jobfile.py')
-rw-r--r-- | src/python/m5/util/jobfile.py | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/python/m5/util/jobfile.py b/src/python/m5/util/jobfile.py index d8c09afd4..ad5b5ff5c 100644 --- a/src/python/m5/util/jobfile.py +++ b/src/python/m5/util/jobfile.py @@ -38,7 +38,7 @@ class Data(object): def update(self, obj): if not isinstance(obj, Data): - raise AttributeError, "can only update from Data object" + raise AttributeError("can only update from Data object") for key,val in obj.__dict__.iteritems(): if key.startswith('_') or key in ('name', 'desc'): @@ -52,22 +52,22 @@ class Data(object): if self.__dict__[key] == val: continue - raise AttributeError, \ - "%s specified more than once old: %s new: %s" % \ - (key, self.__dict__[key], val) + raise AttributeError( + "%s specified more than once old: %s new: %s" % \ + (key, self.__dict__[key], val)) d = self.__dict__[key] for k,v in val.iteritems(): if k in d: - raise AttributeError, \ - "%s specified more than once in %s" % (k, key) + raise AttributeError( + "%s specified more than once in %s" % (k, key)) d[k] = v if hasattr(self, 'system') and hasattr(obj, 'system'): if self.system != obj.system: - raise AttributeError, \ - "conflicting values for system: '%s'/'%s'" % \ - (self.system, obj.system) + raise AttributeError( + "conflicting values for system: '%s'/'%s'" % \ + (self.system, obj.system)) def printinfo(self): if self.name: @@ -96,7 +96,7 @@ class Data(object): def __getitem__(self, key): if key.startswith('_'): - raise KeyError, "Key '%s' not found" % attr + raise KeyError("Key '%s' not found" % attr) return self.__dict__[key] def __iter__(self): @@ -131,8 +131,8 @@ class Job(Data): config = options[0]._config for opt in options: if opt._config != config: - raise AttributeError, \ - "All options are not from the same Configuration" + raise AttributeError( + "All options are not from the same Configuration") self._config = config self._groups = [ opt._group for opt in options ] @@ -309,7 +309,7 @@ class Configuration(Data): def checkchildren(self, kids): for kid in kids: if kid._config != self: - raise AttributeError, "child from the wrong configuration" + raise AttributeError("child from the wrong configuration") def sortgroups(self, groups): groups = [ (grp._number, grp) for grp in groups ] @@ -387,7 +387,7 @@ class Configuration(Data): if job.name == jobname: return job else: - raise AttributeError, "job '%s' not found" % jobname + raise AttributeError("job '%s' not found" % jobname) def job(self, options): self.checkchildren(options) @@ -414,13 +414,12 @@ def JobFile(jobfile): filename = testname break else: - raise AttributeError, \ - "Could not find file '%s'" % jobfile + raise AttributeError("Could not find file '%s'" % jobfile) data = {} execfile(filename, data) if 'conf' not in data: - raise ImportError, 'cannot import name conf from %s' % jobfile + raise ImportError('cannot import name conf from %s' % jobfile) return data['conf'] def main(conf=None): @@ -448,11 +447,11 @@ def main(conf=None): if conf is None: if len(args) != 1: - raise AttributeError, usage + raise AttributeError(usage) conf = JobFile(args[0]) else: if len(args) != 0: - raise AttributeError, usage + raise AttributeError(usage) if both: jobs = conf.alljobs() |