From: pankrat Date: Fri, 5 Sep 2008 16:28:48 +0000 (+0000) Subject: Issue 2176: BuilderWrapper __getattr__ should not raise KeyError X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6983bd63248d03a862eb799e1c3b2009a80f3a48;p=scons.git Issue 2176: BuilderWrapper __getattr__ should not raise KeyError git-svn-id: http://scons.tigris.org/svn/scons/trunk@3341 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 67881eb3..1a4f5f56 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -230,7 +230,7 @@ class BuilderWrapper(MethodWrapper): elif name == 'builder': return self.method else: - return self.__dict__[name] + raise AttributeError, name def __setattr__(self, name, value): if name == 'env': diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 7e6d4ca1..01e7e069 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -916,7 +916,28 @@ class BaseTestCase(unittest.TestCase,TestEnvironmentFixture): assert called_it['target'] == None, called_it assert called_it['source'] == None, called_it + def test_BuilderWrapper_attributes(self): + """Test getting and setting of BuilderWrapper attributes + """ + b1 = Builder() + b2 = Builder() + e1 = Environment() + e2 = Environment() + + e1.Replace(BUILDERS = {'b' : b1}) + bw = e1.b + + assert bw.env is e1 + bw.env = e2 + assert bw.env is e2 + + assert bw.builder is b1 + bw.builder = b2 + assert bw.builder is b2 + self.assertRaises(AttributeError, getattr, bw, 'foobar') + bw.foobar = 42 + assert bw.foobar is 42 # This unit test is currently disabled because we don't think the # underlying method it tests (Environment.BuilderWrapper.execute())