changeset 2629f0b99e8d in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=2629f0b99e8d
description:
        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.

diffstat:

 src/python/m5/SimObject.py |  23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

diffs (34 lines):

diff -r ef8630054b5e -r 2629f0b99e8d src/python/m5/SimObject.py
--- a/src/python/m5/SimObject.py        Tue Feb 14 14:15:30 2012 -0500
+++ b/src/python/m5/SimObject.py        Mon Feb 20 08:11:14 2012 -0800
@@ -922,18 +922,19 @@
 
         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])
+            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
+                except AttributeError:
+                    pass
 
         for n in sorted(self._children.keys()):
             d[self._children[n].get_name()] =  
self._children[n].get_config_as_dict()
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to