[pypy-svn] r33378 - in pypy/branch/even-more-config3/pypy/config: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Oct 17 17:03:55 CEST 2006


Author: cfbolz
Date: Tue Oct 17 17:03:53 2006
New Revision: 33378

Modified:
   pypy/branch/even-more-config3/pypy/config/config.py
   pypy/branch/even-more-config3/pypy/config/test/test_config.py
Log:
(pedronis, cfbolz): make getattr(config, "a.b.c.d") possible


Modified: pypy/branch/even-more-config3/pypy/config/config.py
==============================================================================
--- pypy/branch/even-more-config3/pypy/config/config.py	(original)
+++ pypy/branch/even-more-config3/pypy/config/config.py	Tue Oct 17 17:03:53 2006
@@ -40,6 +40,9 @@
         self.setoption(name, value, 'user')
 
     def __getattr__(self, name):
+        if '.' in name:
+            homeconfig, name = self._cfgimpl_get_home_by_path(name)
+            return getattr(homeconfig, name)
         if name not in self._cfgimpl_values:
             raise AttributeError("%s object has no attribute %s" %
                                  (self.__class__, name))

Modified: pypy/branch/even-more-config3/pypy/config/test/test_config.py
==============================================================================
--- pypy/branch/even-more-config3/pypy/config/test/test_config.py	(original)
+++ pypy/branch/even-more-config3/pypy/config/test/test_config.py	Tue Oct 17 17:03:53 2006
@@ -31,6 +31,7 @@
     assert config.gc.name == 'ref'
     config.gc.name = 'framework'
     assert config.gc.name == 'framework'
+    assert getattr(config, "gc.name") == 'framework'
 
     assert config.objspace == 'std'
     config.objspace = 'logic'



More information about the Pypy-commit mailing list