From 94b60d1247be4ce42eaefafe13e73169bd978bd7 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Tue, 30 Mar 2010 20:06:07 -0700 Subject: Consolidate the exec/eval bits, switch anonfunc to better_exec, etc The methodpool, ${@} expansions, anonymous python functions, event handlers now all run with the same global context, ensuring a consistent environment for them. Added a bb.utils.better_eval function which does an eval() with the same globals as better_exec. (Bitbake rev: 424d7e267b009cc19b8503eadab782736d9597d0) Signed-off-by: Chris Larson Signed-off-by: Richard Purdie --- bitbake/lib/bb/event.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bitbake/lib/bb/event.py') diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index afd5bf57c1..8559858f04 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py @@ -48,13 +48,18 @@ _handlers = {} _ui_handlers = {} _ui_handler_seq = 0 +# For compatibility +bb.utils._context["NotHandled"] = NotHandled +bb.utils._context["Handled"] = Handled + def fire_class_handlers(event, d): for handler in _handlers: h = _handlers[handler] event.data = d if type(h).__name__ == "code": - exec(h) - tmpHandler(event) + locals = {"e": event} + exec h in bb.utils._context, locals + bb.utils.better_eval("tmpHandler(e)", locals) else: h(event) del event.data -- cgit v1.2.3