diff options
author | Steven Knight <knight@baldmt.com> | 2004-10-22 21:57:53 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-10-22 21:57:53 (GMT) |
commit | 79c393d899d7cc8cacac9d8de4aa2689b4f8a9d9 (patch) | |
tree | ed423bde111afa41d9a3058f401308ea81744c37 | |
parent | c7029022abb689e25457a3dc00aced8c1224c389 (diff) | |
download | SCons-79c393d899d7cc8cacac9d8de4aa2689b4f8a9d9.zip SCons-79c393d899d7cc8cacac9d8de4aa2689b4f8a9d9.tar.gz SCons-79c393d899d7cc8cacac9d8de4aa2689b4f8a9d9.tar.bz2 |
Avoid copying __builtin__ when evaluating variables. (Gary Oberbrunner)
-rw-r--r-- | src/CHANGES.txt | 3 | ||||
-rw-r--r-- | src/engine/SCons/Util.py | 26 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 6747261..9845e85 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -154,6 +154,9 @@ RELEASE 0.97 - XXX will not be added to the construction environment unless it's set explicitly by the user or from an Options file. + - Avoid copying __builtin__ values into a construction environment's + dictionary when evaluating construction variables. + From Chris Pawling: - Have the linkloc tool use $MSVS_VERSION to select the Microsoft diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 4e81935..b713b57 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -692,9 +692,22 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=No if gvars is None: gvars = env.Dictionary() + # We're (most likely) going to eval() things. If Python doesn't + # find a __builtin__ value in the global dictionary used for eval(), + # it copies the current __builtin__ values for you. Avoid this by + # setting it explicitly and then deleting, so we don't pollute the + # construction environment Dictionary(ies) that are typically used + # for expansion. + gvars['__builtin__'] = __builtin__ + ss = StringSubber(env, mode, target, source, conv, gvars) result = ss.substitute(strSubst, dict) + try: + del gvars['__builtin__'] + except KeyError: + pass + if is_String(result): # Remove $(-$) pairs and any stuff in between, # if that's appropriate. @@ -929,9 +942,22 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, di if gvars is None: gvars = env.Dictionary() + # We're (most likely) going to eval() things. If Python doesn't + # find a __builtin__ value in the global dictionary used for eval(), + # it copies the current __builtin__ values for you. Avoid this by + # setting it explicitly and then deleting, so we don't pollute the + # construction environment Dictionary(ies) that are typically used + # for expansion. + gvars['__builtins__'] = __builtins__ + ls = ListSubber(env, mode, target, source, conv, gvars) ls.substitute(strSubst, dict, 0) + try: + del gvars['__builtins__'] + except KeyError: + pass + return ls.data def scons_subst_once(strSubst, env, key): |