[gem5-dev] Change in gem5/gem5[master]: python: Switch to using open instead of file
Andreas Sandberg has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/15985 ) Change subject: python: Switch to using open instead of file .. 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 Reviewed-on: https://gem5-review.googlesource.com/c/15985 Reviewed-by: Gabe Black Reviewed-by: Giacomo Travaglini --- M src/python/importer.py M src/python/m5/main.py M src/python/m5/simulate.py M src/python/m5/util/code_formatter.py M src/python/m5/util/grammar.py 5 files changed, 7 insertions(+), 6 deletions(-) Approvals: Gabe Black: Looks good to me, approved Giacomo Travaglini: Looks good to me, approved Andreas Sandberg: Looks good to me, approved diff --git a/src/python/importer.py b/src/python/importer.py index 60b9b35..c54fb49 100644 --- a/src/python/importer.py +++ b/src/python/importer.py @@ -67,7 +67,7 @@ override = os.environ.get('M5_OVERRIDE_PY_SOURCE', 'false').lower() if override in ('true', 'yes') and os.path.exists(abspath): -src = file(abspath, 'r').read() +src = open(abspath, 'r').read() code = compile(src, abspath, 'exec') if os.path.basename(srcfile) == '__init__.py': diff --git a/src/python/m5/main.py b/src/python/m5/main.py index d8c0d92..e4619c0 100644 --- a/src/python/m5/main.py +++ b/src/python/m5/main.py @@ -407,7 +407,7 @@ 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 03cc253..d72dee2 100644 --- a/src/python/m5/simulate.py +++ b/src/python/m5/simulate.py @@ -92,7 +92,7 @@ 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 @@ 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 d48c59b..129fbd0 100644 --- a/src/python/m5/util/code_formatter.py +++ b/src/python/m5/util/code_formatter.py @@ -154,7 +154,7 @@ 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 bb34298..fcd8df2 100644 --- a/src/python/m5/util/grammar.py +++ b/src/python/m5/util/grammar.py @@ -115,7 +115,7 @@ 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: -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/15985 To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: master Gerrit-Change-Id: I35ef8690d97a5243860a64ff985fd22fa86253f1 Gerrit-Change-Number: 15985 Gerrit-PatchSet: 5 Gerrit-Owner: Andreas Sandberg Gerrit-Reviewer: Andreas Sandberg Gerrit-Reviewer: Gabe Black Gerrit-Reviewer: Giacomo Travaglini Gerrit-Reviewer: Jason Lowe-Power Gerrit-MessageType: merged ___ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev
[gem5-dev] Change in gem5/gem5[master]: python: Switch to using open instead of file
Hello Gabe Black, Jason Lowe-Power, I'd like you to reexamine a change. Please visit https://gem5-review.googlesource.com/c/public/gem5/+/15985 to look at the new patch set (#4). Change subject: python: Switch to using open instead of file .. 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 --- M src/python/importer.py M src/python/m5/main.py M src/python/m5/simulate.py M src/python/m5/util/code_formatter.py M src/python/m5/util/grammar.py 5 files changed, 7 insertions(+), 6 deletions(-) -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/15985 To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: master Gerrit-Change-Id: I35ef8690d97a5243860a64ff985fd22fa86253f1 Gerrit-Change-Number: 15985 Gerrit-PatchSet: 4 Gerrit-Owner: Andreas Sandberg Gerrit-Reviewer: Andreas Sandberg Gerrit-Reviewer: Gabe Black Gerrit-Reviewer: Jason Lowe-Power Gerrit-CC: Giacomo Travaglini Gerrit-MessageType: newpatchset ___ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev
[gem5-dev] Change in gem5/gem5[master]: python: Switch to using open instead of file
Andreas Sandberg has uploaded a new patch set (#3). ( https://gem5-review.googlesource.com/c/public/gem5/+/15985 ) Change subject: python: Switch to using open instead of file .. 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 --- M src/python/importer.py M src/python/m5/main.py M src/python/m5/simulate.py M src/python/m5/util/code_formatter.py M src/python/m5/util/grammar.py 5 files changed, 7 insertions(+), 6 deletions(-) -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/15985 To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: master Gerrit-Change-Id: I35ef8690d97a5243860a64ff985fd22fa86253f1 Gerrit-Change-Number: 15985 Gerrit-PatchSet: 3 Gerrit-Owner: Andreas Sandberg Gerrit-CC: Giacomo Travaglini Gerrit-MessageType: newpatchset ___ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev
[gem5-dev] Change in gem5/gem5[master]: python: Switch to using open instead of file
Andreas Sandberg has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/15985 Change subject: python: Switch to using open instead of file .. 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 --- M src/python/importer.py M src/python/m5/main.py M src/python/m5/simulate.py M src/python/m5/util/code_formatter.py 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/python/importer.py b/src/python/importer.py index a5135d3..33ec267 100644 --- a/src/python/importer.py +++ b/src/python/importer.py @@ -70,7 +70,7 @@ override = os.environ.get('M5_OVERRIDE_PY_SOURCE', 'false').lower() if override in ('true', 'yes') and os.path.exists(abspath): -src = file(abspath, 'r').read() +src = open(abspath, 'rb').read() code = compile(src, abspath, 'exec') if os.path.basename(srcfile) == '__init__.py': diff --git a/src/python/m5/main.py b/src/python/m5/main.py index 8884c9e..89a319b 100644 --- a/src/python/m5/main.py +++ b/src/python/m5/main.py @@ -407,7 +407,7 @@ 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 dccd774..6f02327 100644 --- a/src/python/m5/simulate.py +++ b/src/python/m5/simulate.py @@ -92,7 +92,7 @@ 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 @@ 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 5ffc0e0..f556e26 100644 --- a/src/python/m5/util/code_formatter.py +++ b/src/python/m5/util/code_formatter.py @@ -154,7 +154,7 @@ 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() -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/15985 To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: master Gerrit-Change-Id: I35ef8690d97a5243860a64ff985fd22fa86253f1 Gerrit-Change-Number: 15985 Gerrit-PatchSet: 1 Gerrit-Owner: Andreas Sandberg Gerrit-MessageType: newchange ___ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev