DBManager: fix unicode error display table data (fix #13447)

This commit is contained in:
Giuseppe Sucameli 2015-09-30 00:11:16 +02:00
parent ece1169a44
commit 0c480a93c6
2 changed files with 7 additions and 3 deletions

View File

@ -76,7 +76,11 @@ class BaseTableModel(QAbstractTableModel):
elif isinstance(val, (str, unicode)) and len(val) > 300:
# too much data to display, elide the string
return u"%s..." % val[:300]
return unicode(val) # convert to string
try:
return unicode(val) # convert to unicode
except UnicodeDecodeError:
return unicode(val, 'utf-8', 'replace') # convert from utf8 and replace errors (if any)
def headerData(self, section, orientation, role):
if role != Qt.DisplayRole:

View File

@ -38,9 +38,9 @@ class BaseError(Exception):
msg = e
try:
msg = unicode(msg)
msg = unicode(msg) # convert to unicode
except UnicodeDecodeError:
msg = unicode(msg, 'utf-8')
msg = unicode(msg, 'utf-8', 'replace') # convert from utf8 and replace errors (if any)
self.msg = msg
Exception.__init__(self, msg)