summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/cooker.py5
-rw-r--r--bitbake/lib/bb/cookerdata.py1
-rw-r--r--bitbake/lib/bb/utils.py26
3 files changed, 22 insertions, 10 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 41f70ab95a..e8686475b9 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1454,7 +1454,7 @@ class Parser(multiprocessing.Process):
1454 self.quit = quit 1454 self.quit = quit
1455 self.init = init 1455 self.init = init
1456 multiprocessing.Process.__init__(self) 1456 multiprocessing.Process.__init__(self)
1457 self.context = bb.utils._context.copy() 1457 self.context = bb.utils.get_context().copy()
1458 self.handlers = bb.event._handlers.copy() 1458 self.handlers = bb.event._handlers.copy()
1459 1459
1460 def run(self): 1460 def run(self):
@@ -1490,7 +1490,8 @@ class Parser(multiprocessing.Process):
1490 1490
1491 def parse(self, filename, appends, caches_array): 1491 def parse(self, filename, appends, caches_array):
1492 try: 1492 try:
1493 bb.utils._context = self.context.copy() 1493 # Reset our environment and handlers to the original settings
1494 bb.utils.set_context(self.context.copy())
1494 bb.event._handlers = self.handlers.copy() 1495 bb.event._handlers = self.handlers.copy()
1495 return True, bb.cache.Cache.parse(filename, appends, self.cfg, caches_array) 1496 return True, bb.cache.Cache.parse(filename, appends, self.cfg, caches_array)
1496 except Exception as exc: 1497 except Exception as exc:
diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py
index c4a28c86c5..de4331050d 100644
--- a/bitbake/lib/bb/cookerdata.py
+++ b/bitbake/lib/bb/cookerdata.py
@@ -173,6 +173,7 @@ class CookerDataBuilder(object):
173 self.postfiles = params.postfile 173 self.postfiles = params.postfile
174 self.tracking = params.tracking 174 self.tracking = params.tracking
175 175
176 bb.utils.set_context(bb.utils.clean_context())
176 self.data = bb.data.init() 177 self.data = bb.data.init()
177 if self.tracking: 178 if self.tracking:
178 self.data.enableTracking() 179 self.data.enableTracking()
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 1ecc44a01a..7db6e3862f 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -36,12 +36,22 @@ from contextlib import contextmanager
36 36
37logger = logging.getLogger("BitBake.Util") 37logger = logging.getLogger("BitBake.Util")
38 38
39def clean_context():
40 return {
41 "os": os,
42 "bb": bb,
43 "time": time,
44 }
45
46def get_context():
47 return _context
48
49
50def set_context(ctx):
51 _context = ctx
52
39# Context used in better_exec, eval 53# Context used in better_exec, eval
40_context = { 54_context = clean_context()
41 "os": os,
42 "bb": bb,
43 "time": time,
44}
45 55
46def explode_version(s): 56def explode_version(s):
47 r = [] 57 r = []
@@ -343,7 +353,7 @@ def better_exec(code, context, text = None, realfile = "<code>"):
343 if not hasattr(code, "co_filename"): 353 if not hasattr(code, "co_filename"):
344 code = better_compile(code, realfile, realfile) 354 code = better_compile(code, realfile, realfile)
345 try: 355 try:
346 exec(code, _context, context) 356 exec(code, get_context(), context)
347 except Exception as e: 357 except Exception as e:
348 (t, value, tb) = sys.exc_info() 358 (t, value, tb) = sys.exc_info()
349 359
@@ -358,10 +368,10 @@ def better_exec(code, context, text = None, realfile = "<code>"):
358 raise e 368 raise e
359 369
360def simple_exec(code, context): 370def simple_exec(code, context):
361 exec(code, _context, context) 371 exec(code, get_context(), context)
362 372
363def better_eval(source, locals): 373def better_eval(source, locals):
364 return eval(source, _context, locals) 374 return eval(source, get_context(), locals)
365 375
366@contextmanager 376@contextmanager
367def fileslocked(files): 377def fileslocked(files):