bitbake: event/ast: Use better_exec instead of simple_exec
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 21 Aug 2012 16:25:07 +0000 (16:25 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 22 Aug 2012 12:59:57 +0000 (13:59 +0100)
This improves the stacktraces dumped by bitbake when for example anonymous
python functions fail.

Also default to passing code strings to better_exec to match the behaviour of
simple_exec to aid the transition.

(Bitbake rev: 7e8205929ae953731a6854ea80b197847cff5771)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/event.py
bitbake/lib/bb/parse/ast.py
bitbake/lib/bb/utils.py

index 20923b5..fa179d8 100644 (file)
@@ -175,7 +175,7 @@ def register(name, handler):
                 _handlers[name] = noop
                 return
             env = {}
-            bb.utils.simple_exec(code, env)
+            bb.utils.better_exec(code, env)
             func = bb.utils.better_eval(name, env)
             _handlers[name] = func
         else:
index 86f9463..b88d5f5 100644 (file)
@@ -320,7 +320,7 @@ def finalize(fn, d, variant = None):
     code = []
     for funcname in d.getVar("__BBANONFUNCS") or []:
         code.append("%s(d)" % funcname)
-    bb.utils.simple_exec("\n".join(code), {"d": d})
+    bb.utils.better_exec("\n".join(code), {"d": d})
     bb.data.update_data(d)
 
     tasklist = d.getVar('__BBTASKS') or []
index ee4ef73..44a42a0 100644 (file)
@@ -218,13 +218,15 @@ def better_compile(text, file, realfile, mode = "exec"):
 
         raise
 
-def better_exec(code, context, text, realfile = "<code>"):
+def better_exec(code, context, text = None, realfile = "<code>", data = None):
     """
     Similiar to better_compile, better_exec will
     print the lines that are responsible for the
     error.
     """
     import bb.parse
+    if not text:
+        text = code
     if not hasattr(code, "co_filename"):
         code = better_compile(code, realfile, realfile)
     try: