Fix a regression with env.Append().
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 28 Oct 2003 03:39:31 +0000 (03:39 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 28 Oct 2003 03:39:31 +0000 (03:39 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@831 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Environment.py
src/engine/SCons/EnvironmentTests.py
test/Scanner.py

index 794836d92662cf78780d4962f4a8e46209aff5ce..367b54a6e8caa2b487a350e0ebb66e3fc1f22993 100644 (file)
@@ -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.
index e320f0580397d8a88311fb4c232acb0f6b8dad05..6c6ad8a7963f8b7b61fcf574d19e40467a0a6a49 100644 (file)
@@ -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])
index d079feb2ed07675a6d096ef60d0ea7f9359ebbbc..2861f85afd5555d8c27a5367509c79bef2e7bf10 100644 (file)
@@ -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']
index b11805e0c8f08560cc14d58da857724806928b77..610eef715cb5e175bb259922f42a765b1de11255 100644 (file)
@@ -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')