Private GIT

Skip to content
Snippets Groups Projects
Commit eb19c365 authored by miigotu's avatar miigotu
Browse files

Merge pull request #2213 from SiCKRAGETV/text_factory

Revert text factory to may19, until we can fix unicode
parents 77bc0808 455568e4
No related branches found
No related tags found
No related merge requests found
...@@ -57,12 +57,7 @@ class DBConnection(object): ...@@ -57,12 +57,7 @@ class DBConnection(object):
db_locks[self.filename] = threading.Lock() db_locks[self.filename] = threading.Lock()
self.connection = sqlite3.connect(dbFilename(self.filename, self.suffix), 20, check_same_thread=False) self.connection = sqlite3.connect(dbFilename(self.filename, self.suffix), 20, check_same_thread=False)
self.connection.text_factory = self._unicode_text_factory
# 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
db_cons[self.filename] = self.connection db_cons[self.filename] = self.connection
else: else:
...@@ -235,27 +230,10 @@ class DBConnection(object): ...@@ -235,27 +230,10 @@ class DBConnection(object):
def _unicode_text_factory(self, x): def _unicode_text_factory(self, x):
try: try:
# Already unicode, empty string, or ascii # Just revert to the old code for now, until we can fix unicode
x = unicode(x) return unicode(x, 'utf-8')
except Exception: except:
try: return unicode(x, sickbeard.SYS_ENCODING,errors="ignore")
# 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
def _dict_factory(self, cursor, row): def _dict_factory(self, cursor, row):
d = {} d = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment