summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/EnvironmentTests.py14
-rw-r--r--src/engine/SCons/Util.py18
2 files changed, 21 insertions, 11 deletions
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index ec69607..7feb76d 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -1806,6 +1806,20 @@ def exists(env):
env2.Append(FLAGS = 'flag3 flag4')
x = env2.get('FLAGS')
assert x == ['flag1', 'flag2', 'flag3', 'flag4'], x
+ x = env1.get('FLAGS')
+ assert x == ['flag1', 'flag2'], x
+
+ # Ensure that appending directly to a copied CLVar
+ # doesn't modify the original.
+ env1 = self.TestEnvironment(FLAGS = CLVar('flag1 flag2'))
+ x = env1.get('FLAGS')
+ assert x == ['flag1', 'flag2'], x
+ env2 = env1.Clone()
+ env2['FLAGS'] += ['flag3', 'flag4']
+ x = env2.get('FLAGS')
+ assert x == ['flag1', 'flag2', 'flag3', 'flag4'], x
+ x = env1.get('FLAGS')
+ assert x == ['flag1', 'flag2'], x
# Test that the environment stores the toolpath and
# re-uses it for copies.
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index cc6c95e..7a6cb51 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -459,22 +459,18 @@ def _semi_deepcopy_tuple(x):
return tuple(map(semi_deepcopy, x))
d[tuple] = _semi_deepcopy_tuple
-def _semi_deepcopy_inst(x):
- if hasattr(x, '__semi_deepcopy__'):
- return x.__semi_deepcopy__()
- elif isinstance(x, UserDict):
- return x.__class__(_semi_deepcopy_dict(x))
- elif isinstance(x, UserList):
- return x.__class__(_semi_deepcopy_list(x))
- else:
- return x
-d[InstanceType] = _semi_deepcopy_inst
-
def semi_deepcopy(x):
copier = _semi_deepcopy_dispatch.get(type(x))
if copier:
return copier(x)
else:
+ if hasattr(x, '__semi_deepcopy__'):
+ return x.__semi_deepcopy__()
+ elif isinstance(x, UserDict):
+ return x.__class__(_semi_deepcopy_dict(x))
+ elif isinstance(x, UserList):
+ return x.__class__(_semi_deepcopy_list(x))
+
return x