From: Steve Reinhardt Date: Fri, 18 Mar 2005 18:34:28 +0000 (-0500) Subject: Byproducts of aborted attempt to refine 'parent' proxy semantics. X-Git-Tag: m5_1.0_tutorial~68^2~7^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c929ee2c1001b25b2c12ca0256b73ea429ac6052;p=gem5.git Byproducts of aborted attempt to refine 'parent' proxy semantics. Mostly cleanup of mpy_importer.mpy_parse(). python/m5/__init__.py: Move panic() up to top in case we want to use it in mpy_importer (though I ended up not doing that after all). python/m5/config.py: Add a couple of comments and a check for expressions like parent.any.foo (which is illegal). --HG-- extra : convert_revision : dfc99ac9b1a2d91a736ca0b773b6d3c528a4f3cc --- diff --git a/python/m5/__init__.py b/python/m5/__init__.py index 16f48dba3..27bd91749 100644 --- a/python/m5/__init__.py +++ b/python/m5/__init__.py @@ -1,14 +1,14 @@ import sys, os -# the mpy import code is added to the global import meta_path as a -# side effect of this import -from mpy_importer import AddToPath, LoadMpyFile - # define this here so we can use it right away if necessary def panic(string): print >>sys.stderr, 'panic:', string sys.exit(1) +# the mpy import code is added to the global import meta_path as a +# side effect of this import +from mpy_importer import AddToPath, LoadMpyFile + # find the m5 compile options: must be specified as a dict in # __main__.m5_build_env. import __main__ diff --git a/python/m5/config.py b/python/m5/config.py index 712b0cfd1..6c21dce93 100644 --- a/python/m5/config.py +++ b/python/m5/config.py @@ -151,8 +151,11 @@ class Proxy(object): self._multiplier = None def __getattr__(self, attr): + # python uses __bases__ internally for inheritance if attr == '__bases__': return super(Proxy, self).__getattr__(self, attr) + if (self._path == None): + panic("Can't add attributes to 'any' proxy") self._path.append((attr,None)) return self @@ -347,7 +350,7 @@ class MetaConfigNode(type): elif isNullPointer(val): cls._values[key] = val - # process param types from _init_dict, as these may be needed + # process param types from _init_dict first, as these may be needed # by param descriptions also in _init_dict for key,val in cls._init_dict.items(): if isinstance(val, type) and issubclass(val, ParamType):