persist_data: don't allow non-string keys/values

(Bitbake rev: 28958cd55e592853c68f5f2ba79381d1b8dcfb8f)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Chris Larson 2011-04-04 09:37:07 -07:00 committed by Richard Purdie
parent d43e7a91f2
commit 824acff967
1 changed files with 5 additions and 0 deletions

View File

@ -77,6 +77,11 @@ class SQLTable(collections.MutableMapping):
self._execute("DELETE from %s where key=?;" % self.table, [key])
def __setitem__(self, key, value):
if not isinstance(key, basestring):
raise TypeError('Only string keys are supported')
elif not isinstance(value, basestring):
raise TypeError('Only string values are supported')
data = self._execute("SELECT * from %s where key=?;" %
self.table, [key])
exists = len(list(data))