summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/utils.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-30 20:52:56 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-31 09:13:04 +0100
commitd73da22b0e332411ed5552d36910fe15f92c8fac (patch)
treea2a0961cc5ac0e663fda21ae9c9b3cc80e340a92 /bitbake/lib/bb/utils.py
parent672c07de4a96eb67eaafba0873eced44ec9ae1a6 (diff)
downloadpoky-d73da22b0e332411ed5552d36910fe15f92c8fac.tar.gz
bitbake: 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. (Bitbake rev: 85cf22fd0ed26bb7dc7738ef2a10441891f38ae2) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r--bitbake/lib/bb/utils.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 7ab8927608..e9ad68f2d7 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -372,7 +372,7 @@ def _print_exception(t, value, tb, realfile, text, context):
372 finally: 372 finally:
373 logger.error("\n".join(error)) 373 logger.error("\n".join(error))
374 374
375def better_exec(code, context, text = None, realfile = "<code>"): 375def better_exec(code, context, text = None, realfile = "<code>", pythonexception=False):
376 """ 376 """
377 Similiar to better_compile, better_exec will 377 Similiar to better_compile, better_exec will
378 print the lines that are responsible for the 378 print the lines that are responsible for the
@@ -389,6 +389,8 @@ def better_exec(code, context, text = None, realfile = "<code>"):
389 # Error already shown so passthrough, no need for traceback 389 # Error already shown so passthrough, no need for traceback
390 raise 390 raise
391 except Exception as e: 391 except Exception as e:
392 if pythonexception:
393 raise
392 (t, value, tb) = sys.exc_info() 394 (t, value, tb) = sys.exc_info()
393 try: 395 try:
394 _print_exception(t, value, tb, realfile, text, context) 396 _print_exception(t, value, tb, realfile, text, context)