summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/event.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index ec6446d64c..9e64fe5c42 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -150,6 +150,7 @@ def fire_from_worker(event, d):
150 event = pickle.loads(event[7:-8]) 150 event = pickle.loads(event[7:-8])
151 fire_ui_handlers(event, d) 151 fire_ui_handlers(event, d)
152 152
153noop = lambda _: None
153def register(name, handler): 154def register(name, handler):
154 """Register an Event handler""" 155 """Register an Event handler"""
155 156
@@ -161,10 +162,15 @@ def register(name, handler):
161 # handle string containing python code 162 # handle string containing python code
162 if isinstance(handler, basestring): 163 if isinstance(handler, basestring):
163 tmp = "def %s(e):\n%s" % (name, handler) 164 tmp = "def %s(e):\n%s" % (name, handler)
164 comp = bb.utils.better_compile(tmp, "%s(e)" % name, 165 try:
165 "bb.event._registerCode") 166 code = compile(tmp, "%s(e)" % name, "exec")
167 except SyntaxError:
168 logger.error("Unable to register event handler '%s':\n%s", name,
169 ''.join(traceback.format_exc(limit=0)))
170 _handlers[name] = noop
171 return
166 env = {} 172 env = {}
167 bb.utils.simple_exec(comp, env) 173 bb.utils.simple_exec(code, env)
168 func = bb.utils.better_eval(name, env) 174 func = bb.utils.better_eval(name, env)
169 _handlers[name] = func 175 _handlers[name] = func
170 else: 176 else: