From: Chris Larson Date: Wed, 31 Mar 2010 15:59:00 +0000 (-0700) Subject: Make realfile optional for better_exec, using the existing fn in the code object X-Git-Tag: 2011-1~3182 X-Git-Url: https://code.ossystems.io/gitweb?a=commitdiff_plain;h=bac0c60b61941354aaadee5f1ecb2a32749cc8cd;p=openembedded-core.git Make realfile optional for better_exec, using the existing fn in the code object (Bitbake rev: 499a2d28d578cdd6df7cd30ccb79cc2b2796fb65) Signed-off-by: Chris Larson Signed-off-by: Richard Purdie --- diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index e02969c07f..922b7256e3 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py @@ -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 = ""): """ 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)