summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-09-27 21:24:20 (GMT)
committerSteven Knight <knight@baldmt.com>2004-09-27 21:24:20 (GMT)
commiteb15c920b92e7934a6a55ea86623445e3a25a4cb (patch)
tree10174b4f6c649078aff04722fe7555a9935df39b /src
parent50982d8e28f90646890c6b2cb2e9be7e5726e84a (diff)
downloadSCons-eb15c920b92e7934a6a55ea86623445e3a25a4cb.zip
SCons-eb15c920b92e7934a6a55ea86623445e3a25a4cb.tar.gz
SCons-eb15c920b92e7934a6a55ea86623445e3a25a4cb.tar.bz2
Fix env.subst() stack trace on var containing ListAction.
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt3
-rw-r--r--src/engine/SCons/Util.py28
-rw-r--r--src/engine/SCons/UtilTests.py28
3 files changed, 51 insertions, 8 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 4f50aec..7032d69 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -76,6 +76,9 @@ RELEASE 0.97 - XXX
through "chdir" keyword arguments to Action and Builder creation
and calls.
+ - Fix handling of Action ojects (and other callables that don't match
+ our calling arguments) in construction variable expansions.
+
From Clive Levinson:
- Make ParseConfig() recognize and add -mno-cygwin to $LINKFLAGS and
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index afcaf11..984bb02 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -606,10 +606,16 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=No
r.append(self.conv(self.substitute(l, lvars)))
return string.join(r)
elif callable(s):
- s = s(target=self.target,
- source=self.source,
- env=self.env,
- for_signature=(self.mode != SUBST_CMD))
+ try:
+ s = s(target=self.target,
+ source=self.source,
+ env=self.env,
+ for_signature=(self.mode != SUBST_CMD))
+ except TypeError:
+ # This probably indicates that it's a callable
+ # object that doesn't match our calling arguments
+ # (like an Action).
+ s = str(s)
return self.substitute(s, lvars)
elif s is None:
return ''
@@ -753,10 +759,16 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, di
self.substitute(a, lvars, 1)
self.next_word()
elif callable(s):
- s = s(target=self.target,
- source=self.source,
- env=self.env,
- for_signature=(self.mode != SUBST_CMD))
+ try:
+ s = s(target=self.target,
+ source=self.source,
+ env=self.env,
+ for_signature=(self.mode != SUBST_CMD))
+ except TypeError:
+ # This probably indicates that it's a callable
+ # object that doesn't match our calling arguments
+ # (like an Action).
+ s = str(s)
self.substitute(s, lvars, within_list)
elif s is None:
self.this_word()
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py
index 054d0b2..5ac6ec0 100644
--- a/src/engine/SCons/UtilTests.py
+++ b/src/engine/SCons/UtilTests.py
@@ -130,6 +130,14 @@ class UtilTestCase(unittest.TestCase):
def is_literal(self):
return 1
+ class TestCallable:
+ def __init__(self, value):
+ self.value = value
+ def __call__(self):
+ pass
+ def __str__(self):
+ return self.value
+
def function_foo(arg):
pass
@@ -194,6 +202,9 @@ class UtilTestCase(unittest.TestCase):
'RECURSE' : 'foo $RECURSE bar',
'RRR' : 'foo $SSS bar',
'SSS' : '$RRR',
+
+ # Test callables that don't match the calling arguments.
+ 'CALLABLE' : TestCallable('callable-1'),
}
env = DummyEnv(loc)
@@ -307,6 +318,9 @@ class UtilTestCase(unittest.TestCase):
# Bug reported by Christoph Wiedemann.
cvt('$xxx/bin'), '/bin',
+
+ # Tests callables that don't match our calling arguments.
+ '$CALLABLE', 'callable-1',
]
kwargs = {'target' : target, 'source' : source}
@@ -474,6 +488,14 @@ class UtilTestCase(unittest.TestCase):
self.attribute.attr1 = 'attr$1-' + os.path.basename(name)
self.attribute.attr2 = 'attr$2-' + os.path.basename(name)
+ class TestCallable:
+ def __init__(self, value):
+ self.value = value
+ def __call__(self):
+ pass
+ def __str__(self):
+ return self.value
+
target = [ MyNode("./foo/bar.exe"),
MyNode("/bar/baz with spaces.obj"),
MyNode("../foo/baz.obj") ]
@@ -529,6 +551,9 @@ class UtilTestCase(unittest.TestCase):
'RECURSE' : 'foo $RECURSE bar',
'RRR' : 'foo $SSS bar',
'SSS' : '$RRR',
+
+ # Test callable objects that don't match our calling arguments.
+ 'CALLABLE' : TestCallable('callable-2'),
}
env = DummyEnv(loc)
@@ -660,6 +685,9 @@ class UtilTestCase(unittest.TestCase):
'<$AAA', [['<', 'a']],
'>$AAA', [['>', 'a']],
'|$AAA', [['|', 'a']],
+
+ # Test callables that don't match our calling arguments.
+ '$CALLABLE', [['callable-2']],
]
kwargs = {'target' : target, 'source' : source}