Private GIT

Skip to content
Snippets Groups Projects
Commit 455568e4 authored by Dustyn Gibson's avatar Dustyn Gibson
Browse files

Revert text factory to may19, until we can fix unicode

parent 242e719c
Branches
Tags
No related merge requests found
......@@ -57,12 +57,7 @@ class DBConnection(object):
db_locks[self.filename] = threading.Lock()
self.connection = sqlite3.connect(dbFilename(self.filename, self.suffix), 20, check_same_thread=False)
# Lets test without this for awhile. If non-unicode data is getting to the DB, fix it at the source.
# There are too many places we convert when we don't need to,
# sqlite, browsers, python, everything understands unicode
#self.connection.text_factory = self._unicode_text_factory
self.connection.text_factory = self._unicode_text_factory
db_cons[self.filename] = self.connection
else:
......@@ -235,27 +230,10 @@ class DBConnection(object):
def _unicode_text_factory(self, x):
try:
# Already unicode, empty string, or ascii
x = unicode(x)
except Exception:
try:
# most common encoding from web
x = unicode(x, 'utf-8')
except Exception:
try:
# most common from web if utf-8 fails
x = unicode(x, 'latin-1')
except Exception:
try:
# try system encoding before trusting chardet
x = unicode(x, sickbeard.SYS_ENCODING)
except Exception:
try:
# Chardet can be wrong, so try it last before ignoring
x = unicode(x, chardet.detect(x).get('encoding'))
except Exception:
x = unicode(x, sickbeard.SYS_ENCODING, errors="ignore")
return x
# Just revert to the old code for now, until we can fix unicode
return unicode(x, 'utf-8')
except:
return unicode(x, sickbeard.SYS_ENCODING,errors="ignore")
def _dict_factory(self, cursor, row):
d = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment