diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2004-07-10 14:14:51 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2004-07-10 14:14:51 (GMT) |
commit | 5fcefdb32600fa64d3160f031d48fb033150fdb3 (patch) | |
tree | 0fd9800a24ce5719e733573fa11b3aafbc5dc871 /Lib/cgitb.py | |
parent | bf4406971ce34434ed914d17fab70370948d2aab (diff) | |
download | cpython-5fcefdb32600fa64d3160f031d48fb033150fdb3.zip cpython-5fcefdb32600fa64d3160f031d48fb033150fdb3.tar.gz cpython-5fcefdb32600fa64d3160f031d48fb033150fdb3.tar.bz2 |
[Patch #987052 from Thomas Guettler]
Don't output empty tags
Escape page header
Remove <p> before <table> (tidy complains)
Diffstat (limited to 'Lib/cgitb.py')
-rw-r--r-- | Lib/cgitb.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/Lib/cgitb.py b/Lib/cgitb.py index f75a84c..d287001 100644 --- a/Lib/cgitb.py +++ b/Lib/cgitb.py @@ -37,9 +37,23 @@ Content-Type: text/html </table> </table> </table> </table> </table> </font> </font> </font>''' __UNDEF__ = [] # a special sentinel object -def small(text): return '<small>' + text + '</small>' -def strong(text): return '<strong>' + text + '</strong>' -def grey(text): return '<font color="#909090">' + text + '</font>' +def small(text): + if text: + return '<small>' + text + '</small>' + else: + return '' + +def strong(text): + if text: + return '<strong>' + text + '</strong>' + else: + return '' + +def grey(text): + if text: + return '<font color="#909090">' + text + '</font>' + 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 = '<body bgcolor="#f0f0f8">' + pydoc.html.heading( - '<big><big><strong>%s</strong></big></big>' % str(etype), + '<big><big>%s</big></big>' % + strong(pydoc.html.escape(str(etype))), '#ffffff', '#6622aa', pyver + '<br>' + date) + ''' <p>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.</p>''' indent = '<tt>' + small(' ' * 5) + ' </tt>' frames = [] @@ -142,7 +157,7 @@ function calls leading up to the error, in the order they occurred.''' dump.append(name + ' <em>undefined</em>') rows.append('<tr><td>%s</td></tr>' % small(grey(', '.join(dump)))) - frames.append('''<p> + frames.append(''' <table width="100%%" cellspacing=0 cellpadding=0 border=0> %s</table>''' % '\n'.join(rows)) |