Skip to content

Commit 0c480a9

Browse files
committedSep 29, 2015
DBManager: fix unicode error display table data (fix #13447)
1 parent ece1169 commit 0c480a9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
 

‎python/plugins/db_manager/db_plugins/data_model.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ def data(self, index, role):
7676
elif isinstance(val, (str, unicode)) and len(val) > 300:
7777
# too much data to display, elide the string
7878
return u"%s..." % val[:300]
79-
return unicode(val) # convert to string
79+
try:
80+
return unicode(val) # convert to unicode
81+
except UnicodeDecodeError:
82+
return unicode(val, 'utf-8', 'replace') # convert from utf8 and replace errors (if any)
83+
8084

8185
def headerData(self, section, orientation, role):
8286
if role != Qt.DisplayRole:

‎python/plugins/db_manager/db_plugins/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def __init__(self, e):
3838
msg = e
3939

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

4545
self.msg = msg
4646
Exception.__init__(self, msg)

0 commit comments

Comments
 (0)