summaryrefslogtreecommitdiffstats
path: root/lib/bb/data_smart.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-10-05 20:19:31 -0700
committerChris Larson <chris_larson@mentor.com>2010-10-05 20:34:03 -0700
commit8d661ce0c303e8d69f17c1d095545d5ed086d1d5 (patch)
tree773ce7cc01762b58ff461652b12c87642cb65b8a /lib/bb/data_smart.py
parentf264cb6d43472525ad787b0887764ea696ec52ba (diff)
downloadbitbake-8d661ce0c303e8d69f17c1d095545d5ed086d1d5.tar.gz
Fix __getitem__ for DataSmart
Ensure it raises KeyError for a missing key, this is required to use this as a mapping in various places, e.g. as locals in an eval. Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/bb/data_smart.py')
-rw-r--r--lib/bb/data_smart.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index aac13490d..64fae2d7d 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -125,7 +125,7 @@ class DataSmart(MutableMapping):
for var in vars:
name = var[:-l]
try:
- self[name] = self[var]
+ self.setVar(name, self.getVar(var, False))
except Exception:
logger.info("Untracked delVar")
@@ -343,7 +343,11 @@ class DataSmart(MutableMapping):
return len(frozenset(self))
def __getitem__(self, item):
- return self.getVar(item, False)
+ value = self.getVar(item, False)
+ if value is None:
+ raise KeyError(item)
+ else:
+ return value
def __setitem__(self, var, value):
self.setVar(var, value)