diff options
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 26 |
1 files changed, 18 insertions, 8 deletions
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 | ||
37 | logger = logging.getLogger("BitBake.Util") | 37 | logger = logging.getLogger("BitBake.Util") |
38 | 38 | ||
39 | def clean_context(): | ||
40 | return { | ||
41 | "os": os, | ||
42 | "bb": bb, | ||
43 | "time": time, | ||
44 | } | ||
45 | |||
46 | def get_context(): | ||
47 | return _context | ||
48 | |||
49 | |||
50 | def 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 | ||
46 | def explode_version(s): | 56 | def 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 | ||
360 | def simple_exec(code, context): | 370 | def simple_exec(code, context): |
361 | exec(code, _context, context) | 371 | exec(code, get_context(), context) |
362 | 372 | ||
363 | def better_eval(source, locals): | 373 | def better_eval(source, locals): |
364 | return eval(source, _context, locals) | 374 | return eval(source, get_context(), locals) |
365 | 375 | ||
366 | @contextmanager | 376 | @contextmanager |
367 | def fileslocked(files): | 377 | def fileslocked(files): |