Make realfile optional for better_exec, using the existing fn in the code object

(Bitbake rev: 499a2d28d578cdd6df7cd30ccb79cc2b2796fb65)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
Chris Larson 2010-03-31 08:59:00 -07:00 committed by Richard Purdie
parent 947577a77d
commit bac0c60b61
1 changed files with 4 additions and 2 deletions

View 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)