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 /src/engine/SCons/Util.py | |
| parent | c7029022abb689e25457a3dc00aced8c1224c389 (diff) | |
| download | SCons-79c393d899d7cc8cacac9d8de4aa2689b4f8a9d9.zip SCons-79c393d899d7cc8cacac9d8de4aa2689b4f8a9d9.tar.gz SCons-79c393d899d7cc8cacac9d8de4aa2689b4f8a9d9.tar.bz2 | |
Avoid copying __builtin__ when evaluating variables. (Gary Oberbrunner)
Diffstat (limited to 'src/engine/SCons/Util.py')
| -rw-r--r-- | src/engine/SCons/Util.py | 26 |
1 files changed, 26 insertions, 0 deletions
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): |
