diff options
author | Steve Reinhardt <steve.reinhardt@amd.com> | 2012-02-20 08:11:14 -0800 |
---|---|---|
committer | Steve Reinhardt <steve.reinhardt@amd.com> | 2012-02-20 08:11:14 -0800 |
commit | e121708e08465344a2ab4df8f562159dffdf18d6 (patch) | |
tree | f0d4e1272add19b6086d4e655c6b8442b4acc6d3 | |
parent | 6cf9f182f678e4ddf2a2b98a5093a7418353217c (diff) | |
download | gem5-e121708e08465344a2ab4df8f562159dffdf18d6.tar.xz |
SimObject: make get_config_as_dict() tolerate undefined params
Without this patch, undefined params cause a cryptic KeyError
in multidict inside get_config_as_dict(). This patch lets
undefined params through get_config_as_dict() so they can
once again generate meaningful error messages later on in
the configuration process.
-rw-r--r-- | src/python/m5/SimObject.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py index 78138b083..a2de7a086 100644 --- a/src/python/m5/SimObject.py +++ b/src/python/m5/SimObject.py @@ -922,18 +922,19 @@ class SimObject(object): for param in sorted(self._params.keys()): value = self._values.get(param) - try: - # Use native type for those supported by JSON and - # strings for everything else. skipkeys=True seems - # to not work as well as one would hope - if type(self._values[param].value) in \ - [str, unicode, int, long, float, bool, None]: - d[param] = self._values[param].value - else: - d[param] = str(self._values[param]) - - except AttributeError: - pass + if value != None: + try: + # Use native type for those supported by JSON and + # strings for everything else. skipkeys=True seems + # to not work as well as one would hope + if type(self._values[param].value) in \ + [str, unicode, int, long, float, bool, None]: + d[param] = self._values[param].value + else: + d[param] = str(self._values[param]) + + except AttributeError: + pass for n in sorted(self._children.keys()): d[self._children[n].get_name()] = self._children[n].get_config_as_dict() |