From c7719545ac9ee9e8201d20b85ae90a979d64c57f Mon Sep 17 00:00:00 2001 From: Bill Dengler Date: Sat, 2 May 2015 03:48:36 -0400 Subject: [PATCH] All keys will be converted to bitestrings on deshelve and to unicode on shelve. This will probably break i18n majorly, so a better fix should be implemented at some point. --- src/sessionmanager/session.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sessionmanager/session.py b/src/sessionmanager/session.py index 6b715523..856e0ee5 100644 --- a/src/sessionmanager/session.py +++ b/src/sessionmanager/session.py @@ -368,7 +368,10 @@ class Session(object): shelf=shelve.open(paths.config_path(shelfname),'c') for key,value in self.db.items(): print(key) - shelf[key]=value + if type(key) != str or type(key) != unicode: + output.speak("Uh oh, while shelving the database, a key of type " + type(key) + " has been found. It will be converted to type str, but this will cause all sorts of problems on deshelve. Please bring this to the attention of the " + application.name + " developers immediately. More information about the error will be written to the error log.") + log.error("Uh oh, " + str(key) + " is of type " + type(key) + "!") + shelf[str(key)]=value shelf.close() except: output.speak("An exception occurred while shelving the " + application.name + " database. It will be deleted and rebuilt automatically. If this error persists, send the error log to the " + application.name + " developers.",True) @@ -381,7 +384,7 @@ class Session(object): try: shelf=shelve.open(paths.config_path(shelfname),'c') for key,value in shelf.items(): - self.db[key]=value + self.db[unicode(key)]=value shelf.close() except: output.speak("An exception occurred while deshelving the " + application.name + " database. It will be deleted and rebuilt automatically. If this error persists, send the error log to the " + application.name + " developers.",True)