Skip to content
Permalink
Browse files

[py3] Followup bad0d3e: Don't decode unencoded strings

  • Loading branch information
m-kuhn committed Jun 7, 2016
1 parent 7a8d9dd commit d0feea57c1dbdb8b9a33095955ea0df4d4906998
Showing with 11 additions and 2 deletions.
  1. +11 −2 python/utils.py
@@ -65,9 +65,18 @@


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

0 comments on commit d0feea5

Please sign in to comment.
You can’t perform that action at this time.