From: stevenknight Date: Tue, 28 Oct 2003 03:39:31 +0000 (+0000) Subject: Fix a regression with env.Append(). X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=900e9fdd8dbb8d5b3965fbcb3535269f70838a6d;p=scons.git Fix a regression with env.Append(). git-svn-id: http://scons.tigris.org/svn/scons/trunk@831 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 794836d9..367b54a6 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -14,6 +14,9 @@ RELEASE X.XX - XXX, XX XXX XXXX XX:XX:XX -XXXX - Fix use of CPPDEFINES with C++ source files. + - Fix env.Append() when the operand is an object with a __cmp__() + method (like a Scanner instance). + From Gary Oberbrunner: - Fix how the man page un-indents after examples in some browsers. diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index e320f058..6c6ad8a7 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -427,14 +427,16 @@ class Base: self._dict[key] = kw[key] elif SCons.Util.is_List(self._dict[key]) and not \ SCons.Util.is_List(kw[key]): - if not kw[key] is None and kw[key] != '': + if kw[key]: self._dict[key] = self._dict[key] + [ kw[key] ] + #self._dict[key] = map(None, self._dict[key] + [ kw[key] ]) elif SCons.Util.is_List(kw[key]) and not \ SCons.Util.is_List(self._dict[key]): - if self._dict[key] is None or self._dict[key] == '': - self._dict[key] = kw[key] - else: + if self._dict[key]: self._dict[key] = [ self._dict[key] ] + kw[key] + else: + self._dict[key] = kw[key] + #self._dict[key] = map(None, self._dict[key] + [ kw[key] ]) elif SCons.Util.is_Dict(self._dict[key]) and \ SCons.Util.is_Dict(kw[key]): self._dict[key].update(kw[key]) diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index d079feb2..2861f85a 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -721,7 +721,7 @@ class EnvironmentTestCase(unittest.TestCase): b1 = Environment()['BUILDERS'] b2 = Environment()['BUILDERS'] assert b1 == b2, diff_dict(b1, b2) - + import UserList UL = UserList.UserList env1 = Environment(AAA = 'a', @@ -777,6 +777,23 @@ class EnvironmentTestCase(unittest.TestCase): assert env1['QQQ2'] == UL(['', 'Q2']), env1['QQQ2'] assert env1['QQQ3'] == UL(['', 'Q3']), env1['QQQ3'] + class C: + def __init__(self, name): + self.name = name + def __str__(self): + return self.name + def __cmp__(self, other): + raise "should not compare" + + ccc = C('ccc') + + env2 = Environment(CCC1 = ['c1'], CCC2 = ccc) + env2.Append(CCC1 = ccc, CCC2 = ['c2']) + assert env2['CCC1'][0] == 'c1', env2['CCC1'] + assert env2['CCC1'][1] is ccc, env2['CCC1'] + assert env2['CCC2'][0] is ccc, env2['CCC2'] + assert env2['CCC2'][1] == 'c2', env2['CCC2'] + env3 = Environment(X = {'x1' : 7}) env3.Append(X = {'x1' : 8, 'x2' : 9}, Y = {'y1' : 10}) assert env3['X'] == {'x1': 8, 'x2': 9}, env3['X'] diff --git a/test/Scanner.py b/test/Scanner.py index b11805e0..610eef71 100644 --- a/test/Scanner.py +++ b/test/Scanner.py @@ -82,8 +82,9 @@ k2scan = env.Scanner(name = 'k2', argument = None, skeys = ['.k2']) -scanners = Environment().Dictionary('SCANNERS') -env = Environment(SCANNERS = scanners + [kscan, k2scan]) +env = Environment() +env.Append(SCANNERS = kscan) +env.Append(SCANNERS = [k2scan]) env.Command('foo', 'foo.k', r'%s build.py $SOURCES $TARGET')