uilib.py
changeset 10784 21bb9a00adeb
parent 10703 3cb87b61b067
child 10817 7b154e0fa194
equal deleted inserted replaced
10783:02cc22d7d339 10784:21bb9a00adeb
    26 
    26 
    27 import csv
    27 import csv
    28 import re
    28 import re
    29 from io import StringIO
    29 from io import StringIO
    30 
    30 
    31 from six import PY3, text_type, binary_type, string_types, integer_types
    31 from six import PY2, PY3, text_type, binary_type, string_types, integer_types
    32 
    32 
    33 from logilab.mtconverter import xml_escape, html_unescape
    33 from logilab.mtconverter import xml_escape, html_unescape
    34 from logilab.common.date import ustrftime
    34 from logilab.common.date import ustrftime
    35 from logilab.common.deprecation import deprecated
    35 from logilab.common.deprecation import deprecated
    36 
    36 
   465     """return a unicode ReST formated traceback"""
   465     """return a unicode ReST formated traceback"""
   466     res = [u'Traceback\n---------\n::\n']
   466     res = [u'Traceback\n---------\n::\n']
   467     for stackentry in traceback.extract_tb(info[2]):
   467     for stackentry in traceback.extract_tb(info[2]):
   468         res.append(u'\tFile %s, line %s, function %s' % tuple(stackentry[:3]))
   468         res.append(u'\tFile %s, line %s, function %s' % tuple(stackentry[:3]))
   469         if stackentry[3]:
   469         if stackentry[3]:
   470             res.append(u'\t  %s' % stackentry[3].decode('utf-8', 'replace'))
   470             data = xml_escape(stackentry[3])
       
   471             if PY2:
       
   472                 data = data.decode('utf-8', 'replace')
       
   473             res.append(u'\t  %s' % data)
   471     res.append(u'\n')
   474     res.append(u'\n')
   472     try:
   475     try:
   473         res.append(u'\t Error: %s\n' % exception)
   476         res.append(u'\t Error: %s\n' % exception)
   474     except Exception:
   477     except Exception:
   475         pass
   478         pass
   499         strings.append(u'<b>File</b> <b class="file">%s</b>, <b>line</b> '
   502         strings.append(u'<b>File</b> <b class="file">%s</b>, <b>line</b> '
   500                        u'<b class="line">%s</b>, <b>function</b> '
   503                        u'<b class="line">%s</b>, <b>function</b> '
   501                        u'<b class="function">%s</b>:<br/>'%(
   504                        u'<b class="function">%s</b>:<br/>'%(
   502             xml_escape(stackentry[0]), stackentry[1], xml_escape(stackentry[2])))
   505             xml_escape(stackentry[0]), stackentry[1], xml_escape(stackentry[2])))
   503         if stackentry[3]:
   506         if stackentry[3]:
   504             string = xml_escape(stackentry[3]).decode('utf-8', 'replace')
   507             string = xml_escape(stackentry[3])
       
   508             if PY2:
       
   509                 string = string.decode('utf-8', 'replace')
   505             strings.append(u'&#160;&#160;%s<br/>\n' % (string))
   510             strings.append(u'&#160;&#160;%s<br/>\n' % (string))
   506         # add locals info for each entry
   511         # add locals info for each entry
   507         try:
   512         try:
   508             local_context = tcbk.tb_frame.f_locals
   513             local_context = tcbk.tb_frame.f_locals
   509             html_info = []
   514             html_info = []