summaryrefslogtreecommitdiff
path: root/src/python/m5
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2019-01-25 12:03:21 +0000
committerAndreas Sandberg <andreas.sandberg@arm.com>2019-02-12 16:44:21 +0000
commitb3195c455bf5aed70d2543684f3c0bc7f36c8fcf (patch)
treead4a65410ac87f4bb2b1679f3a7843413d488d87 /src/python/m5
parent626e8faf42db0c75a9f8d054487c411f7d35ccd4 (diff)
downloadgem5-b3195c455bf5aed70d2543684f3c0bc7f36c8fcf.tar.xz
python: Switch to using open instead of file
Python 3 doesn't support the file(name, mode) syntax which has been deprecated in favour of open. Change-Id: I35ef8690d97a5243860a64ff985fd22fa86253f1 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/15985 Reviewed-by: Gabe Black <gabeblack@google.com> Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Diffstat (limited to 'src/python/m5')
-rw-r--r--src/python/m5/main.py2
-rw-r--r--src/python/m5/simulate.py5
-rw-r--r--src/python/m5/util/code_formatter.py2
-rw-r--r--src/python/m5/util/grammar.py2
4 files changed, 6 insertions, 5 deletions
diff --git a/src/python/m5/main.py b/src/python/m5/main.py
index d8c0d923b..e4619c09d 100644
--- a/src/python/m5/main.py
+++ b/src/python/m5/main.py
@@ -407,7 +407,7 @@ def main(*args):
sys.path = [ os.path.dirname(sys.argv[0]) ] + sys.path
filename = sys.argv[0]
- filedata = file(filename, 'r').read()
+ filedata = open(filename, 'r').read()
filecode = compile(filedata, filename, 'exec')
scope = { '__file__' : filename,
'__name__' : '__m5_main__' }
diff --git a/src/python/m5/simulate.py b/src/python/m5/simulate.py
index 03cc253e9..d72dee222 100644
--- a/src/python/m5/simulate.py
+++ b/src/python/m5/simulate.py
@@ -92,7 +92,7 @@ def instantiate(ckpt_dir=None):
for obj in root.descendants(): obj.unproxyParams()
if options.dump_config:
- ini_file = file(os.path.join(options.outdir, options.dump_config), 'w')
+ ini_file = open(os.path.join(options.outdir, options.dump_config), 'w')
# Print ini sections in sorted order for easier diffing
for obj in sorted(root.descendants(), key=lambda o: o.path()):
obj.print_ini(ini_file)
@@ -101,7 +101,8 @@ def instantiate(ckpt_dir=None):
if options.json_config:
try:
import json
- json_file = file(os.path.join(options.outdir, options.json_config), 'w')
+ json_file = open(
+ os.path.join(options.outdir, options.json_config), 'w')
d = root.get_config_as_dict()
json.dump(d, json_file, indent=4)
json_file.close()
diff --git a/src/python/m5/util/code_formatter.py b/src/python/m5/util/code_formatter.py
index d48c59b26..129fbd0e3 100644
--- a/src/python/m5/util/code_formatter.py
+++ b/src/python/m5/util/code_formatter.py
@@ -154,7 +154,7 @@ class code_formatter(object):
self._data = []
def write(self, *args):
- f = file(os.path.join(*args), "w")
+ f = open(os.path.join(*args), "w")
for data in self._data:
f.write(data)
f.close()
diff --git a/src/python/m5/util/grammar.py b/src/python/m5/util/grammar.py
index bb3429866..fcd8df2c9 100644
--- a/src/python/m5/util/grammar.py
+++ b/src/python/m5/util/grammar.py
@@ -115,7 +115,7 @@ class Grammar(object):
def parse_file(self, f, **kwargs):
if isinstance(f, basestring):
source = f
- f = file(f, 'r')
+ f = open(f, 'r')
elif isinstance(f, file):
source = f.name
else: