summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-05-10 18:26:20 (GMT)
committerSteven Knight <knight@baldmt.com>2003-05-10 18:26:20 (GMT)
commit088746100c58e3bf3dd20a00d8328e635e6c0b24 (patch)
treeca589ce39f942d53b40e87cfec89a1e123194217
parent2333feeb8864c753a8834a45f0743876e28386e7 (diff)
downloadSCons-088746100c58e3bf3dd20a00d8328e635e6c0b24.zip
SCons-088746100c58e3bf3dd20a00d8328e635e6c0b24.tar.gz
SCons-088746100c58e3bf3dd20a00d8328e635e6c0b24.tar.bz2
Interpolate the null string for illegal list subscripts.
-rw-r--r--src/CHANGES.txt3
-rw-r--r--src/engine/SCons/Util.py4
-rw-r--r--src/engine/SCons/UtilTests.py14
3 files changed, 19 insertions, 2 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 7717ce6..d441604 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -77,6 +77,9 @@ RELEASE 0.14 - XXX
- Add internal SCons.Node.FS.{Dir,File}.Entry() methods.
+ - Interpolate the null string if an out-of-range subscript is used
+ for a construction variable.
+
From Damyan Pepper:
- Quote the "Entering directory" message like Make.
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 8d81437..3b97907 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -456,7 +456,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None):
key = key[1:-1]
try:
e = eval(key, global_vars, local_vars)
- except NameError:
+ except (IndexError, NameError, TypeError):
return '\0\5'
if callable(e):
# We wait to evaluate callables until the end of everything
@@ -524,7 +524,7 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None):
key = key[1:-1]
try:
e = eval(key, global_vars, local_vars)
- except NameError:
+ except (IndexError, NameError, TypeError):
return '\0\5'
if callable(e):
e = e(target=target, source=source, env=env,
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py
index a48b302..84655a9 100644
--- a/src/engine/SCons/UtilTests.py
+++ b/src/engine/SCons/UtilTests.py
@@ -227,6 +227,20 @@ class UtilTestCase(unittest.TestCase):
newcom = scons_subst("$FOO $BAZ $BAR", DummyEnv(glob))
assert newcom == "BAR $FOO BAR", newcom
+ # Test that we don't blow up even if they subscript something
+ # in ways they "can't."
+ glob = { "FOO" : "BAR",
+ "NOTHING" : "" ,
+ "NONE" : None }
+ newcom = scons_subst("${FOO[0]}", DummyEnv(glob))
+ assert newcom == "B", newcom
+ newcom = scons_subst("${FOO[7]}", DummyEnv(glob))
+ assert newcom == "", newcom
+ newcom = scons_subst("${NOTHING[1]}", DummyEnv(glob))
+ assert newcom == "", newcom
+ newcom = scons_subst("${NONE[2]}", DummyEnv(glob))
+ assert newcom == "", newcom
+
def test_splitext(self):
assert splitext('foo') == ('foo','')
assert splitext('foo.bar') == ('foo','.bar')