[1.52,4/5] utils: Ensure shell function failure in python logging is correct

Message ID 910ced8c16f982722ce9fe06c561a7a71eca9e58.1647223687.git.anuj.mittal@intel.com
State Accepted, archived
Commit 23a6f11b089b14382c21d431edf34fa7224c66bf
Headers show
Series [1.52,1/5] contrib: Fix hash server Dockerfile dependencies | expand

Commit Message

Mittal, Anuj March 14, 2022, 2:13 a.m. UTC
From: Richard Purdie <richard.purdie@linuxfoundation.org>

If a python function exec_func() calls a shell task, the logging wasn't working
correctly in all cases since the exception was turned into a BBHandledException()
and the logfile piece was lost which is handled at the top task level.

The easiest way to avoid this is to allow the ExecutionError exceptions to
be raised to a higher level, we don't need the traceback for them.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 7cae11f558f9ff5fd05ef23b789aaef92fb5a327)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
---
 lib/bb/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 1a515897..cd442dcd 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -401,7 +401,7 @@  def better_exec(code, context, text = None, realfile = "<code>", pythonexception
         code = better_compile(code, realfile, realfile)
     try:
         exec(code, get_context(), context)
-    except (bb.BBHandledException, bb.parse.SkipRecipe, bb.data_smart.ExpansionError):
+    except (bb.BBHandledException, bb.parse.SkipRecipe, bb.data_smart.ExpansionError, bb.process.ExecutionError):
         # Error already shown so passthrough, no need for traceback
         raise
     except Exception as e: