summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Util.py
diff options
context:
space:
mode:
authoredA-qa mort-ora-y <edA-qa@disemia.com>2012-05-06 09:11:11 +0200
committeredA-qa mort-ora-y <edA-qa@disemia.com>2012-05-06 09:11:11 +0200
commita10c5b8cfeae168eb39cf92c59166501c2bd4c96 (patch)
tree2406d6521e8bb04188b0efa79d860b291c1f6dae /src/engine/SCons/Util.py
parent4ed4c0db27ab349cce3f0f6653bd6c2e61064734 (diff)
downloadscons-a10c5b8cfeae168eb39cf92c59166501c2bd4c96.tar.gz
better fix for issue 2821 -- avoid direct copies of the BuilderDict as it is ambiguous/corrupts the original environment
Diffstat (limited to 'src/engine/SCons/Util.py')
-rw-r--r--src/engine/SCons/Util.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 2523edac..822d5249 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -430,15 +430,15 @@ def to_String_for_signature(obj, to_String_for_subst=to_String_for_subst,
# references to anything else it finds.
#
# A special case is any object that has a __semi_deepcopy__() method,
-# which we invoke to create the copy, which is used by the BuilderDict
-# class because of its extra initialization argument.
+# which we invoke to create the copy. Currently only used by
+# BuilderDict to actually prevent the copy operation (as invalid on that object)
#
# The dispatch table approach used here is a direct rip-off from the
# normal Python copy module.
_semi_deepcopy_dispatch = d = {}
-def _semi_deepcopy_dict(x):
+def semi_deepcopy_dict(x, exclude = [] ):
copy = {}
for key, val in x.items():
# The regular Python copy.deepcopy() also deepcopies the key,
@@ -447,9 +447,10 @@ def _semi_deepcopy_dict(x):
# copy[semi_deepcopy(key)] = semi_deepcopy(val)
#
# Doesn't seem like we need to, but we'll comment it just in case.
- copy[key] = semi_deepcopy(val)
+ if key not in exclude:
+ copy[key] = semi_deepcopy(val)
return copy
-d[dict] = _semi_deepcopy_dict
+d[dict] = semi_deepcopy_dict
def _semi_deepcopy_list(x):
return list(map(semi_deepcopy, x))
@@ -467,14 +468,13 @@ def semi_deepcopy(x):
if hasattr(x, '__semi_deepcopy__') and callable(x.__semi_deepcopy__):
return x.__semi_deepcopy__()
elif isinstance(x, UserDict):
- return x.__class__(_semi_deepcopy_dict(x))
+ return x.__class__(semi_deepcopy_dict(x))
elif isinstance(x, UserList):
return x.__class__(_semi_deepcopy_list(x))
return x
-
class Proxy(object):
"""A simple generic Proxy class, forwarding all calls to
subject. So, for the benefit of the python newbie, what does