This commit is contained in:
Kovid Goyal 2015-02-15 12:33:46 +05:30
parent 12271efe3d
commit bbbcc7774e

View File

@ -106,7 +106,12 @@ class DBPrefs(dict): # {{{
self.db.execute('DELETE FROM preferences WHERE key=?', (key,))
def __setitem__(self, key, val):
if not self.disable_setting and val != self[key]:
if not self.disable_setting:
try:
current_val = self[key]
except KeyError:
current_val = object()
if val != current_val:
raw = self.to_raw(val)
self.db.execute('INSERT OR REPLACE INTO preferences (key,val) VALUES (?,?)', (key, raw))
dict.__setitem__(self, key, val)