summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Douard <david.douard@logilab.fr>2006-05-12 10:38:57 +0200
committerDavid Douard <david.douard@logilab.fr>2006-05-12 10:38:57 +0200
commitb6e789a717b909f0e18c2a9e85e16bc96028bc7e (patch)
treea0b29e57d8f22176b1b5b94be6c8b49bb0d67d20
parent57b5b001686ee7e0080382c7025ee20bf77acd98 (diff)
downloadlogilab-common-b6e789a717b909f0e18c2a9e85e16bc96028bc7e.tar.gz
workaround for a pb with encodings when building the HTML page of a traceback
-rw-r--r--html.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/html.py b/html.py
index 14bd184..e564df0 100644
--- a/html.py
+++ b/html.py
@@ -10,19 +10,21 @@
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-""" Copyright (c) 2002-2003 LOGILAB S.A. (Paris, FRANCE).
+""" Copyright (c) 2002-2006 LOGILAB S.A. (Paris, FRANCE).
http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__revision__ = "$Id: html.py,v 1.5 2003-09-12 11:54:47 syt Exp $"
+import traceback
+from xml.sax.saxutils import escape
+
# mk html traceback error #####################################################
+
def html_traceback(info, exception,
- title='', encoding='ISO-8859-1', body = '') :
+ title='', encoding='ISO-8859-1', body=''):
""" return an html formatted traceback from python exception infos.
"""
- import traceback
- from xml.sax.saxutils import escape
#typ, value, tbck = info
stacktb = traceback.extract_tb(info[2]) #tbck)
strings = []
@@ -30,7 +32,6 @@ def html_traceback(info, exception,
strings.append('<div class="error_body">')
strings.append(body)
strings.append('</div>')
-
if title:
strings.append('<h1 class="error">%s</h1>'% escape(title))
strings.append('<p class="error">%s</p>' % escape(str(exception)))
@@ -41,7 +42,10 @@ def html_traceback(info, exception,
'<b class="function">%s</b>:<br/>'%(
escape(stackentry[0]), stackentry[1], stackentry[2]))
if stackentry[3]:
- string = escape(stackentry[3]).encode(encoding)
+ string = escape(repr(stackentry[3])[1:-1])#.encode(encoding)
strings.append('&nbsp;&nbsp;%s<br/>\n' % string)
strings.append('</div>')
- return '\n'.join(strings)
+ tbstr = '\n'.join(strings)
+ #if encoding != 'unicode':
+ # tbstr = tbstr.encode(encoding)
+ return tbstr