]> code.ossystems Code Review - openembedded-core.git/commitdiff
Make realfile optional for better_exec, using the existing fn in the code object
authorChris Larson <chris_larson@mentor.com>
Wed, 31 Mar 2010 15:59:00 +0000 (08:59 -0700)
committerRichard Purdie <rpurdie@linux.intel.com>
Tue, 4 Jan 2011 14:36:54 +0000 (14:36 +0000)
(Bitbake rev: 499a2d28d578cdd6df7cd30ccb79cc2b2796fb65)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
bitbake/lib/bb/utils.py

index e02969c07f32f29c86bb64ca93220f43719e363c..922b7256e3de5cc9f0543dc97ccbc9430f971c93 100644 (file)
@@ -334,13 +334,15 @@ def better_compile(text, file, realfile, mode = "exec"):
                 bb.msg.error(bb.msg.domain.Util, line)
         raise
 
-def better_exec(code, context, text, realfile):
+def better_exec(code, context, text, realfile = "<code>"):
     """
     Similiar to better_compile, better_exec will
     print the lines that are responsible for the
     error.
     """
     import bb.parse
+    if not hasattr(code, "co_filename"):
+        code = better_compile(code, realfile, realfile)
     try:
         exec(code, _context, context)
     except:
@@ -350,7 +352,7 @@ def better_exec(code, context, text, realfile):
             raise
 
         # print the Header of the Error Message
-        bb.msg.error(bb.msg.domain.Util, "There was an error when executing a python function in: %s" % realfile)
+        bb.msg.error(bb.msg.domain.Util, "There was an error when executing a python function in: %s" % code.co_filename)
         bb.msg.error(bb.msg.domain.Util, "Exception:%s Message:%s" % (t, value))
 
         # Strip 'us' from the stack (better_exec call)