Skip to content

Commit

Permalink
Properly handle filsystem character encoding when showing warnings
Browse files Browse the repository at this point in the history
Fix #14567
  • Loading branch information
m-kuhn committed Jun 6, 2016
1 parent c59350a commit bad0d3e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions python/utils.py
Expand Up @@ -65,11 +65,9 @@


def showWarning(message, category, filename, lineno, file=None, line=None):
stk = ""
for s in traceback.format_stack()[:-2]:
stk += s.decode('utf-8', 'replace') if hasattr(s, 'decode') else s
stk = ''.join([s.decode(sys.getfilesystemencoding()) for s in traceback.format_stack()[:-2]])
QgsMessageLog.logMessage(
"warning:%s\ntraceback:%s" % (warnings.formatwarning(message, category, filename, lineno), stk),
u"warning:{}\ntraceback:{}".format(warnings.formatwarning(message, category, filename.decode(sys.getfilesystemencoding()), lineno), stk),
QCoreApplication.translate("Python", "Python warning")
)

Expand Down

0 comments on commit bad0d3e

Please sign in to comment.