summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-01-04 01:54:14 (GMT)
committerSteven Knight <knight@baldmt.com>2005-01-04 01:54:14 (GMT)
commit1a8f24ce912546177b9b03447db5db342576ab69 (patch)
tree9fe54780cfcfd1d2bc8426fe3fbaa936ebdf6085 /src
parentbf0edb7f66d1585a88f19184800b0d63729be91d (diff)
downloadSCons-1a8f24ce912546177b9b03447db5db342576ab69.zip
SCons-1a8f24ce912546177b9b03447db5db342576ab69.tar.gz
SCons-1a8f24ce912546177b9b03447db5db342576ab69.tar.bz2
Get rid of the self-referential permanent __env__ variable in favor of adding it to the new lvars() dictionary on each substitution.
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Environment.py21
-rw-r--r--src/engine/SCons/EnvironmentTests.py15
2 files changed, 8 insertions, 28 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 8c2e767..96403f1 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -250,18 +250,9 @@ class SubstitutionEnvironment:
self.ans = SCons.Node.Alias.default_ans
self.lookup_list = SCons.Node.arg2nodes_lookups
self._dict = kw.copy()
- self._dict['__env__'] = self
def __cmp__(self, other):
- # Since an Environment now has an '__env__' construction variable
- # that refers to itself, delete that variable to avoid infinite
- # loops when comparing the underlying dictionaries in some Python
- # versions (*cough* 1.5.2 *cough*)...
- sdict = self._dict.copy()
- del sdict['__env__']
- odict = other._dict.copy()
- del odict['__env__']
- return cmp(sdict, odict)
+ return cmp(self._dict, other._dict)
def __delitem__(self, key):
"__cache_reset__"
@@ -299,10 +290,7 @@ class SubstitutionEnvironment:
return self._dict.has_key(key)
def items(self):
- "Emulates the items() method of dictionaries."""
- result = self._dict.items()
- result = filter(lambda t: t[0] != '__env__', result)
- return result
+ return self._dict.items()
def arg2nodes(self, args, node_factory=_null, lookup_list=_null):
if node_factory is _null:
@@ -364,6 +352,7 @@ class SubstitutionEnvironment:
"""
gvars = self.gvars()
lvars = self.lvars()
+ lvars['__env__'] = self
return SCons.Util.scons_subst(string, self, raw, target, source, gvars, lvars, conv)
def subst_kw(self, kw, raw=0, target=None, source=None):
@@ -380,6 +369,7 @@ class SubstitutionEnvironment:
the documentation for that function."""
gvars = self.gvars()
lvars = self.lvars()
+ lvars['__env__'] = self
return SCons.Util.scons_subst_list(string, self, raw, target, source, gvars, lvars, conv)
def subst_path(self, path):
@@ -494,7 +484,6 @@ class Base(SubstitutionEnvironment):
self.lookup_list = SCons.Node.arg2nodes_lookups
self._dict = our_deepcopy(SCons.Defaults.ConstructionEnvironment)
- self._dict['__env__'] = self
self._dict['BUILDERS'] = BuilderDict(self._dict['BUILDERS'], self)
if platform is None:
@@ -727,7 +716,6 @@ class Base(SubstitutionEnvironment):
"""
clone = copy.copy(self)
clone._dict = our_deepcopy(self._dict)
- clone['__env__'] = clone
try:
cbd = clone._dict['BUILDERS']
clone._dict['BUILDERS'] = BuilderDict(cbd, clone)
@@ -1418,7 +1406,6 @@ class OverrideEnvironment(SubstitutionEnvironment):
if __debug__: logInstanceCreation(self, 'OverrideEnvironment')
self.__dict__['__subject'] = subject
self.__dict__['overrides'] = overrides
- self.__dict__['overrides']['__env__'] = self
# Methods that make this class act like a proxy.
def __getattr__(self, name):
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index a0b1615..87e2e44 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -155,7 +155,7 @@ class SubstitutionTestCase(unittest.TestCase):
"""Test initializing a SubstitutionEnvironment
"""
env = SubstitutionEnvironment()
- assert env['__env__'] is env, env['__env__']
+ assert not env.has_key('__env__')
def test___cmp__(self):
"""Test comparing SubstitutionEnvironments
@@ -338,7 +338,7 @@ class SubstitutionTestCase(unittest.TestCase):
"""Test the base class gvars() method"""
env = SubstitutionEnvironment()
gvars = env.gvars()
- assert gvars == {'__env__' : env}, gvars
+ assert gvars == {}, gvars
def test_lvars(self):
"""Test the base class lvars() method"""
@@ -549,9 +549,6 @@ class SubstitutionTestCase(unittest.TestCase):
assert env2['ONE'] == "won", env2['ONE']
assert env['ONE'] == 1, env['ONE']
- assert env['__env__'] is env, env['__env__']
- assert env2['__env__'] is env2, env2['__env__']
-
class BaseTestCase(unittest.TestCase):
@@ -566,8 +563,8 @@ class BaseTestCase(unittest.TestCase):
env2 = Environment(XXX = 'x', YYY = 'y')
assert env1 == env2, diff_env(env1, env2)
- assert env1['__env__'] is env1, env1['__env__']
- assert env2['__env__'] is env2, env2['__env__']
+ assert not env1.has_key('__env__')
+ assert not env2.has_key('__env__')
def test_get(self):
"""Test the get() method."""
@@ -1260,10 +1257,6 @@ def exists(env):
assert env3.Dictionary('ZZZ') == 'z3'
assert env1 == env1copy
- assert env1['__env__'] is env1, env1['__env__']
- assert env2['__env__'] is env2, env2['__env__']
- assert env3['__env__'] is env3, env3['__env__']
-
# Ensure that lists and dictionaries are
# deep copied, but not instances.
class TestA: