[bitbake-devel] build/utils: Fix broken exception handling

Submitted by Richard Purdie on May 30, 2014, 2:56 p.m. | Patch ID: 73017


Message ID 1401461771.31309.53.camel@ted
State New
Headers show

Commit Message

Richard Purdie May 30, 2014, 2:56 p.m.
Checking for explicit exception names is bad, we also want to be able top
rely on inheritance. Fix these checks to be part of the real except clauses
so SkipPackage is recognised as being inherited from SkipRecipe.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 1a17547..6b70ce5 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -242,10 +242,9 @@  def exec_func_python(func, d, runfile, cwd=None):
         comp = utils.better_compile(code, func, bbfile)
         utils.better_exec(comp, {"d": d}, code, bbfile)
+    except (bb.parse.SkipRecipe, bb.build.FuncFailed):
+        raise
-        if sys.exc_info()[0] in (bb.parse.SkipRecipe, bb.build.FuncFailed):
-            raise
         raise FuncFailed(func, None)
         bb.debug(2, "Python function %s finished" % func)
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index c179394..96d8218 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -354,16 +354,11 @@  def better_exec(code, context, text = None, realfile = "<code>"):
         code = better_compile(code, realfile, realfile)
         exec(code, get_context(), context)
-    except bb.BBHandledException:
-        # Error already shown so passthrough
-        raise
-    except bb.data_smart.ExpansionError:
+    except (bb.BBHandledException, bb.parse.SkipRecipe, bb.build.FuncFailed, bb.data_smart.ExpansionError):
+        # Error already shown so passthrough, no need for traceback
     except Exception as e:
         (t, value, tb) = sys.exc_info()
-        if t in [bb.parse.SkipRecipe, bb.build.FuncFailed]:
-            raise
             _print_exception(t, value, tb, realfile, text, context)
         except Exception as e: