summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-12-28 07:59:31 (GMT)
committerSteven Knight <knight@baldmt.com>2002-12-28 07:59:31 (GMT)
commit2875346f645fe24a249122069b1568fcff032643 (patch)
treeff42fa38b655c64873028e4b43bac090b509f24f /src
parentee46aa600c5aa266f0904c686e656ab545375820 (diff)
downloadSCons-2875346f645fe24a249122069b1568fcff032643.zip
SCons-2875346f645fe24a249122069b1568fcff032643.tar.gz
SCons-2875346f645fe24a249122069b1568fcff032643.tar.bz2
Have the Environment.get() method return None as the default, like the standard Python get() method. (Lachlan O'Dea)
Diffstat (limited to 'src')
-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():