diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-30 20:52:56 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-30 21:22:21 +0100 |
commit | 85cf22fd0ed26bb7dc7738ef2a10441891f38ae2 (patch) | |
tree | 191613ef1b51ce572ae59e32d4555ac0ec35c096 /lib/bb/utils.py | |
parent | 69ef6c8a9db02bfa0e3fac72481ec26586a29a01 (diff) | |
download | bitbake-contrib-85cf22fd0ed26bb7dc7738ef2a10441891f38ae2.tar.gz |
build/utils: Allow python functions to execute with real exception handling
With the code as it stands today it not possible to execute a python function
and get "normal" python exception handling behaviour. If a python function
raises an exception, it forces a traceback to be printed and the exception
becomes a FuncFailed exception.
This adds in a parameter 'pythonexception' which allows standard python
exceptions to be passed unchanged with no traceback. Ultimately we may want
to change to this convention in various places but at least it means we can
start to add sane functions now.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/utils.py')
-rw-r--r-- | lib/bb/utils.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py index 7ab892760..e9ad68f2d 100644 --- a/lib/bb/utils.py +++ b/lib/bb/utils.py @@ -372,7 +372,7 @@ def _print_exception(t, value, tb, realfile, text, context): finally: logger.error("\n".join(error)) -def better_exec(code, context, text = None, realfile = "<code>"): +def better_exec(code, context, text = None, realfile = "<code>", pythonexception=False): """ Similiar to better_compile, better_exec will print the lines that are responsible for the @@ -389,6 +389,8 @@ def better_exec(code, context, text = None, realfile = "<code>"): # Error already shown so passthrough, no need for traceback raise except Exception as e: + if pythonexception: + raise (t, value, tb) = sys.exc_info() try: _print_exception(t, value, tb, realfile, text, context) |