From: Andrew M. Kuchling Date: Sat, 10 Jul 2004 14:14:51 +0000 (+0000) Subject: [Patch #987052 from Thomas Guettler] X-Git-Tag: v2.4a2~345 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5fcefdb32600fa64d3160f031d48fb033150fdb3;p=python [Patch #987052 from Thomas Guettler] Don't output empty tags Escape page header Remove

before (tidy complains) --- diff --git a/Lib/cgitb.py b/Lib/cgitb.py index f75a84ce94..d2870016a6 100644 --- a/Lib/cgitb.py +++ b/Lib/cgitb.py @@ -37,9 +37,23 @@ Content-Type: text/html
''' __UNDEF__ = [] # a special sentinel object -def small(text): return '' + text + '' -def strong(text): return '' + text + '' -def grey(text): return '' + text + '' +def small(text): + if text: + return '' + text + '' + else: + return '' + +def strong(text): + if text: + return '' + text + '' + else: + return '' + +def grey(text): + if text: + return '' + text + '' + else: + return '' def lookup(name, frame, locals): """Find the value for a given name in the given environment.""" @@ -88,10 +102,11 @@ def html((etype, evalue, etb), context=5): pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable date = time.ctime(time.time()) head = '' + pydoc.html.heading( - '%s' % str(etype), + '%s' % + strong(pydoc.html.escape(str(etype))), '#ffffff', '#6622aa', pyver + '
' + date) + '''

A problem occurred in a Python script. Here is the sequence of -function calls leading up to the error, in the order they occurred.''' +function calls leading up to the error, in the order they occurred.

''' indent = '' + small(' ' * 5) + ' ' frames = [] @@ -142,7 +157,7 @@ function calls leading up to the error, in the order they occurred.''' dump.append(name + ' undefined') rows.append('%s' % small(grey(', '.join(dump)))) - frames.append('''

+ frames.append(''' %s
''' % '\n'.join(rows))