diff options
author | R David Murray <rdmurray@bitdance.com> | 2012-10-27 18:42:47 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2012-10-27 18:42:47 (GMT) |
commit | 252cd0e4e0b11c7d13e24146617ad48e80feca43 (patch) | |
tree | 7322c3b62a62be259ce6cc15fb01446bcb152f31 /Lib/cgitb.py | |
parent | bc876a2d4a7b8aa9aedd5da6b62fe391092c3b3c (diff) | |
download | cpython-252cd0e4e0b11c7d13e24146617ad48e80feca43.zip cpython-252cd0e4e0b11c7d13e24146617ad48e80feca43.tar.gz cpython-252cd0e4e0b11c7d13e24146617ad48e80feca43.tar.bz2 |
#12890: don't emit <p> tags in text mode when logdir specified.
Patch by Jeff McNeil.
Diffstat (limited to 'Lib/cgitb.py')
-rw-r--r-- | Lib/cgitb.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/cgitb.py b/Lib/cgitb.py index 7b52c8e..6da40e8 100644 --- a/Lib/cgitb.py +++ b/Lib/cgitb.py @@ -293,14 +293,19 @@ class Hook: if self.logdir is not None: suffix = ['.txt', '.html'][self.format=="html"] (fd, path) = tempfile.mkstemp(suffix=suffix, dir=self.logdir) + try: file = os.fdopen(fd, 'w') file.write(doc) file.close() - msg = '<p> %s contains the description of this error.' % path + msg = '%s contains the description of this error.' % path except: - msg = '<p> Tried to save traceback to %s, but failed.' % path - self.file.write(msg + '\n') + msg = 'Tried to save traceback to %s, but failed.' % path + + if self.format == 'html': + self.file.write('<p>%s</p>\n' % msg) + else: + self.file.write(msg + '\n') try: self.file.flush() except: pass |