summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-03-24 18:58:59 -0700
committerChris Larson <chris_larson@mentor.com>2010-03-24 19:01:02 -0700
commit6a73dda60f50e9b3e5513795d1ec7207d1446de2 (patch)
tree04d554ed74178a27f2e9b8c5d4cbc2397fae381c
parente1e4ccf203e38070eeafd31a622671996cff61a1 (diff)
downloadbitbake-6a73dda60f50e9b3e5513795d1ec7207d1446de2.tar.gz
data_smart: be explicit about what we make available to eval'd python code
Signed-off-by: Chris Larson <chris_larson@mentor.com>
-rw-r--r--lib/bb/data_smart.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index dac7fb705..9067d54bf 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -39,6 +39,11 @@ __setvar_keyword__ = ["_append","_prepend"]
__setvar_regexp__ = re.compile('(?P<base>.*?)(?P<keyword>_append|_prepend)(_(?P<add>.*))?')
__expand_var_regexp__ = re.compile(r"\${[^{}]+}")
__expand_python_regexp__ = re.compile(r"\${@.+?}")
+_expand_globals = {
+ "os": os,
+ "bb": bb,
+ "time": time,
+}
class DataSmart:
@@ -50,6 +55,7 @@ class DataSmart:
self._seen_overrides = seen
self.expand_cache = {}
+ self.expand_locals = {"d": self}
def expand(self,s, varname):
def var_sub(match):
@@ -66,8 +72,7 @@ class DataSmart:
def python_sub(match):
import bb
code = match.group()[3:-1]
- locals()['d'] = self
- s = eval(code)
+ s = eval(code, _expand_globals, self.expand_locals)
if type(s) == types.IntType: s = str(s)
return s