Have the Environment.get() method return None as the default, like the standard Pytho...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 28 Dec 2002 07:59:31 +0000 (07:59 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 28 Dec 2002 07:59:31 +0000 (07:59 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@532 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Environment.py
src/engine/SCons/EnvironmentTests.py

index eebe766613b61b4b707dc3632c94a88fcd990d39..a02dc5c30a4cfe1ad4015e4e472a8e7e5d82ea0b 100644 (file)
@@ -30,6 +30,10 @@ RELEASE 0.10 - XXX
   - Add a Clean() method to support removing user-specified targets
     when using the -c option.
 
+  From Lachlan O'Dea:
+
+  - Make the Environment.get() method return None by default.
+
   From Anthony Roach:
 
   - Add SetJobs() and GetJobs() methods to allow configuration of the
index 480169e78bf8029821f064345baa81821823308d..8861a99e5d2528d0705b0a678fa7b860bcf5b246 100644 (file)
@@ -457,7 +457,7 @@ class Environment:
         else:
             return self
 
-    def get(self, key, default):
+    def get(self, key, default=None):
         "Emulates the get() method of dictionaries."""
         return self._dict.get(key, default)
 
index 0d0d7da90810aa1f184c16bcdeeed016d01643ee..ff8942473698d7fecbc1a806526cf51f84a5182b 100644 (file)
@@ -683,6 +683,19 @@ class EnvironmentTestCase(unittest.TestCase):
         assert env['TOOL2'] == 222, env
         assert env['AAA'] == 'aaa', env
 
+    def test_get(self):
+        """Test the get() method."""
+        env = Environment(aaa = 'AAA')
+
+        x = env.get('aaa')
+        assert x == 'AAA', x
+        x = env.get('aaa', 'XXX')
+        assert x == 'AAA', x
+        x = env.get('bbb')
+        assert x is None, x
+        x = env.get('bbb', 'XXX')
+        assert x == 'XXX', x
+
 if __name__ == "__main__":
     suite = unittest.makeSuite(EnvironmentTestCase, 'test_')
     if not unittest.TextTestRunner().run(suite).wasSuccessful():