From b6e789a717b909f0e18c2a9e85e16bc96028bc7e Mon Sep 17 00:00:00 2001 From: David Douard Date: Fri, 12 May 2006 10:38:57 +0200 Subject: workaround for a pb with encodings when building the HTML page of a traceback --- html.py | 18 +++++++++++------- 1 file 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('
') strings.append(body) strings.append('
') - if title: strings.append('

%s

'% escape(title)) strings.append('

%s

' % escape(str(exception))) @@ -41,7 +42,10 @@ def html_traceback(info, exception, '%s:
'%( 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('  %s
\n' % string) strings.append('') - return '\n'.join(strings) + tbstr = '\n'.join(strings) + #if encoding != 'unicode': + # tbstr = tbstr.encode(encoding) + return tbstr -- cgit v1.2.1