mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-07-18 06:06:06 -04:00
Saving unicode keys as string objects in cache database
This commit is contained in:
@@ -381,10 +381,11 @@ class Session(object):
|
||||
if type(key) != str and type(key) != unicode:
|
||||
output.speak("Uh oh, while shelving the database, a key of type " + str(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.",True)
|
||||
log.error("Uh oh, " + str(key) + " is of type " + str(type(key)) + "!")
|
||||
# Convert unicode objects to UTF-8 strings before shelve these objects.
|
||||
if type(value) == list and self.settings["general"]["persist_size"] != -1 and len(value) > self.settings["general"]["persist_size"]:
|
||||
shelf[str(key)]=value[self.settings["general"]["persist_size"]:]
|
||||
shelf[str(key.encode("utf-8"))]=value[self.settings["general"]["persist_size"]:]
|
||||
else:
|
||||
shelf[str(key)]=value
|
||||
shelf[str(key.encode("utf-8"))]=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)
|
||||
@@ -401,7 +402,7 @@ class Session(object):
|
||||
try:
|
||||
shelf=shelve.open(paths.config_path(shelfname),'c')
|
||||
for key,value in shelf.items():
|
||||
self.db[unicode(key)]=value
|
||||
self.db[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)
|
||||
|
Reference in New Issue
Block a user