summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2014-05-21 15:29:40 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-05-29 13:18:07 +0100
commit2d3478c97b7c7a2f5b12a8be302d8ea5ba4e1277 (patch)
tree9e4938f09988ab3b5f3b715eed4c5a719f945cd6
parentd865692e8b76a1da80c80788946978f150f2c34b (diff)
downloadbitbake-2d3478c97b7c7a2f5b12a8be302d8ea5ba4e1277.tar.gz
data_smart: Fix an unusual variable reference bug
If you try: Y = "" Y_remove = "X" in OE-Core, bitbake will crash with a KeyError during expansion. The reason is that no expansion of the empty value is attempted but removal from is it and hence no varparse data is present for it in the expand_cache. If the value is empty, there is nothing to remove so the best fix is simply not to check for None but check it has any value. Also add a test for this error so it doesn't get reintroduced. (Bitbake rev: af3ce0fc0280e6642fa35de400f75fdbabf329b1) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/data_smart.py2
-rw-r--r--lib/bb/tests/data.py5
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index e4bdb2fdd..2a1ef9019 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -610,7 +610,7 @@ class DataSmart(MutableMapping):
else:
cachename = var + "[" + flag + "]"
value = self.expand(value, cachename)
- if value is not None and flag == "_content" and local_var is not None and "_removeactive" in local_var:
+ if value and flag == "_content" and local_var is not None and "_removeactive" in local_var:
filtered = filter(lambda v: v not in local_var["_removeactive"],
value.split(" "))
value = " ".join(filtered)
diff --git a/lib/bb/tests/data.py b/lib/bb/tests/data.py
index ee66b22e2..228f72c1f 100644
--- a/lib/bb/tests/data.py
+++ b/lib/bb/tests/data.py
@@ -253,6 +253,11 @@ class TestConcatOverride(unittest.TestCase):
bb.data.update_data(self.d)
self.assertEqual(self.d.getVar("TEST_TEST", True), "bar bar")
+ def test_empty_remove(self):
+ self.d.setVar("TEST", "")
+ self.d.setVar("TEST_remove", "val")
+ bb.data.update_data(self.d)
+ self.assertEqual(self.d.getVar("TEST", True), "")
class TestOverrides(unittest.TestCase):
def setUp(self):