Skip to content

Commit

Permalink
DBManager: fix data conversion to unicode (errors='replace' should be…
Browse files Browse the repository at this point in the history
… enough)
  • Loading branch information
brushtyler committed Sep 30, 2015
1 parent a7cd198 commit 401f43c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 2 additions & 5 deletions python/plugins/db_manager/db_plugins/data_model.py
Expand Up @@ -75,11 +75,8 @@ def data(self, index, role):
return None
elif isinstance(val, (str, unicode)) and len(val) > 300:
# too much data to display, elide the string
return u"%s..." % val[:300]
try:
return unicode(val) # convert to unicode
except UnicodeDecodeError:
return unicode(val, 'utf-8', 'replace') # convert from utf8 and replace errors (if any)
val = val[:300]
return unicode(val, 'utf-8', 'replace') # convert from utf8 and replace errors (if any)


def headerData(self, section, orientation, role):
Expand Down
5 changes: 1 addition & 4 deletions python/plugins/db_manager/db_plugins/plugin.py
Expand Up @@ -37,10 +37,7 @@ def __init__(self, e):
else:
msg = e

try:
msg = unicode(msg) # convert to unicode
except UnicodeDecodeError:
msg = unicode(msg, 'utf-8', 'replace') # convert from utf8 and replace errors (if any)
msg = unicode(msg, 'utf-8', 'replace') # convert from utf8 and replace errors (if any)

self.msg = msg
Exception.__init__(self, msg)
Expand Down

0 comments on commit 401f43c

Please sign in to comment.