From 34982a079f6b89b53c9b6fd5c379431f7953c87b Mon Sep 17 00:00:00 2001 From: stevenknight Date: Sun, 6 Nov 2005 03:25:46 +0000 Subject: [PATCH] Fix AppendUnique and PrependUnique concatenating strings to lists. (Patrick Mezard) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1380 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 3 +++ src/engine/SCons/Environment.py | 8 ++++++-- src/engine/SCons/EnvironmentTests.py | 24 ++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index de7bf8ec..56881786 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -417,6 +417,9 @@ RELEASE 0.97 - XXX one in the build directory, too, to avoid dangling files left over from previous runs when a source file is removed. + - Allow AppendUnique() and PrependUnique() to append strings (and + other atomic objects) to lists. + From Georg Mischler: - Remove the space after the -o option when invoking the Borland diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index ce8e3742..38346364 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -747,8 +747,10 @@ class Base(SubstitutionEnvironment): else: dk = self._dict[key] if SCons.Util.is_List(dk): + # By elimination, val is not a list. Since dk is a + # list, wrap val in a list first. if not val in dk: - self._dict[key] = dk + val + self._dict[key] = dk + [val] else: self._dict[key] = self._dict[key] + val self.scanner_map_delete(kw) @@ -1044,8 +1046,10 @@ class Base(SubstitutionEnvironment): else: dk = self._dict[key] if SCons.Util.is_List(dk): + # By elimination, val is not a list. Since dk is a + # list, wrap val in a list first. if not val in dk: - self._dict[key] = val + dk + self._dict[key] = [val] + dk else: self._dict[key] = val + dk self.scanner_map_delete(kw) diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index caf8b4a2..a397d4fb 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -1187,26 +1187,38 @@ def exists(env): env = Environment(AAA1 = 'a1', AAA2 = 'a2', AAA3 = 'a3', + AAA4 = 'a4', + AAA5 = 'a5', BBB1 = ['b1'], BBB2 = ['b2'], BBB3 = ['b3'], + BBB4 = ['b4'], + BBB5 = ['b5'], CCC1 = '', CCC2 = '') env.AppendUnique(AAA1 = 'a1', AAA2 = ['a2'], AAA3 = ['a3', 'b', 'c', 'a3'], + AAA4 = 'a4.new', + AAA5 = ['a5.new'], BBB1 = 'b1', BBB2 = ['b2'], BBB3 = ['b3', 'c', 'd', 'b3'], + BBB4 = 'b4.new', + BBB5 = ['b5.new'], CCC1 = 'c1', CCC2 = ['c2']) assert env['AAA1'] == 'a1a1', env['AAA1'] assert env['AAA2'] == ['a2'], env['AAA2'] assert env['AAA3'] == ['a3', 'b', 'c'], env['AAA3'] + assert env['AAA4'] == 'a4a4.new', env['AAA4'] + assert env['AAA5'] == ['a5', 'a5.new'], env['AAA5'] assert env['BBB1'] == ['b1'], env['BBB1'] assert env['BBB2'] == ['b2'], env['BBB2'] assert env['BBB3'] == ['b3', 'c', 'd'], env['BBB3'] + assert env['BBB4'] == ['b4', 'b4.new'], env['BBB4'] + assert env['BBB5'] == ['b5', 'b5.new'], env['BBB5'] assert env['CCC1'] == 'c1', env['CCC1'] assert env['CCC2'] == ['c2'], env['CCC2'] @@ -1720,25 +1732,37 @@ f5: \ env = Environment(AAA1 = 'a1', AAA2 = 'a2', AAA3 = 'a3', + AAA4 = 'a4', + AAA5 = 'a5', BBB1 = ['b1'], BBB2 = ['b2'], BBB3 = ['b3'], + BBB4 = ['b4'], + BBB5 = ['b5'], CCC1 = '', CCC2 = '') env.PrependUnique(AAA1 = 'a1', AAA2 = ['a2'], AAA3 = ['a3', 'b', 'c', 'a3'], + AAA4 = 'a4.new', + AAA5 = ['a5.new'], BBB1 = 'b1', BBB2 = ['b2'], BBB3 = ['b3', 'b', 'c', 'b3'], + BBB4 = 'b4.new', + BBB5 = ['b5.new'], CCC1 = 'c1', CCC2 = ['c2']) assert env['AAA1'] == 'a1a1', env['AAA1'] assert env['AAA2'] == ['a2'], env['AAA2'] assert env['AAA3'] == ['b', 'c', 'a3'], env['AAA3'] + assert env['AAA4'] == 'a4.newa4', env['AAA4'] + assert env['AAA5'] == ['a5.new', 'a5'], env['AAA5'] assert env['BBB1'] == ['b1'], env['BBB1'] assert env['BBB2'] == ['b2'], env['BBB2'] assert env['BBB3'] == ['b', 'c', 'b3'], env['BBB3'] + assert env['BBB4'] == ['b4.new', 'b4'], env['BBB4'] + assert env['BBB5'] == ['b5.new', 'b5'], env['BBB5'] assert env['CCC1'] == 'c1', env['CCC1'] assert env['CCC2'] == ['c2'], env['CCC2'] -- 2.26.2