# HG changeset patch # User Julien Cristau # Date 1444668221 -7200 # Node ID 21bb9a00adebfa798d4adfd47e85b43b152a5807 # Parent 02cc22d7d339fb523ada541b038f7802f00a607c [uilib] fix traceback on python3 diff -r 02cc22d7d339 -r 21bb9a00adeb uilib.py --- a/uilib.py Mon Oct 12 18:43:05 2015 +0200 +++ b/uilib.py Mon Oct 12 18:43:41 2015 +0200 @@ -28,7 +28,7 @@ import re from io import StringIO -from six import PY3, text_type, binary_type, string_types, integer_types +from six import PY2, PY3, text_type, binary_type, string_types, integer_types from logilab.mtconverter import xml_escape, html_unescape from logilab.common.date import ustrftime @@ -467,7 +467,10 @@ for stackentry in traceback.extract_tb(info[2]): res.append(u'\tFile %s, line %s, function %s' % tuple(stackentry[:3])) if stackentry[3]: - res.append(u'\t %s' % stackentry[3].decode('utf-8', 'replace')) + data = xml_escape(stackentry[3]) + if PY2: + data = data.decode('utf-8', 'replace') + res.append(u'\t %s' % data) res.append(u'\n') try: res.append(u'\t Error: %s\n' % exception) @@ -501,7 +504,9 @@ u'%s:
'%( xml_escape(stackentry[0]), stackentry[1], xml_escape(stackentry[2]))) if stackentry[3]: - string = xml_escape(stackentry[3]).decode('utf-8', 'replace') + string = xml_escape(stackentry[3]) + if PY2: + string = string.decode('utf-8', 'replace') strings.append(u'  %s
\n' % (string)) # add locals info for each entry try: