From 8f18898e85ade3233502acd0dbc7cf9cd416d880 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Tue, 10 Jan 2012 10:17:33 -0600 Subject: [PATCH] config: Fix json output for Python lt 2.6. --- src/python/m5/simulate.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/python/m5/simulate.py b/src/python/m5/simulate.py index 29d14f75d..38129592c 100644 --- a/src/python/m5/simulate.py +++ b/src/python/m5/simulate.py @@ -31,7 +31,6 @@ import atexit import os import sys -import json # import the SWIG-wrapped main C++ functions import internal @@ -74,10 +73,14 @@ def instantiate(ckpt_dir=None): ini_file.close() if options.json_config: - json_file = file(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() + try: + import json + json_file = file(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() + except ImportError: + pass # Initialize the global statistics -- 2.30.2