python: Update use of exec to work with Python 3

Python 3 uses 'exec(code, globals)' instead of 'exec code in
globals'. Switch to the newer syntax since it is supported by Python
2.7. Also, move check_tracing out of main to work around a bug in
Python 2.7.

Change-Id: I6d390160f58783e1b038a572b64cdf3ff09535fa
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/15986
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
This commit is contained in:
Andreas Sandberg
2019-01-25 12:04:31 +00:00
parent b3195c455b
commit 31dff7faa0
5 changed files with 18 additions and 17 deletions

View File

@@ -417,7 +417,7 @@ def JobFile(jobfile):
raise AttributeError("Could not find file '%s'" % jobfile)
data = {}
execfile(filename, data)
exec(compile(open(filename).read(), filename, 'exec'), data)
if 'conf' not in data:
raise ImportError('cannot import name conf from %s' % jobfile)
return data['conf']