Skip to content
Browse files

Properly handle filsystem character encoding when showing warnings

Fix #14567
  • Loading branch information
m-kuhn committed Jun 6, 2016
1 parent c59350a commit bad0d3e4b637f92c9210b0b677210f5390ba786e
Showing with 2 additions and 4 deletions.
  1. +2 −4 python/
@@ -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]])
"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")

0 comments on commit bad0d3e

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