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. (Bitbake rev: 8d661ce0c303e8d69f17c1d095545d5ed086d1d5) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
parent
6491ed9e2e
commit
f3406dd288
|
@ -150,7 +150,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")
|
||||
|
||||
|
@ -366,7 +366,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)
|
||||
|
|
Loading…
Reference in New Issue