summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/CHANGES.txt4
-rw-r--r--src/engine/SCons/Environment.py2
-rw-r--r--src/engine/SCons/EnvironmentTests.py13
3 files changed, 18 insertions, 1 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index eebe766..a02dc5c 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -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
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 480169e..8861a99 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -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)
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 0d0d7da..ff89424 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -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():