summaryrefslogtreecommitdiff
path: root/Lib/cgitb.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-10-27 14:55:25 -0400
committerR David Murray <rdmurray@bitdance.com>2012-10-27 14:55:25 -0400
commitc4b8e05092b5aa018dd74f8563037b23d3c6756e (patch)
treeebfe4f6eeaa503b4a2c6783daa7f15ed762c7bd1 /Lib/cgitb.py
parent0b3014dda01b6ed3fc805cbfce37a9dc6f0d0fa1 (diff)
parent252cd0e4e0b11c7d13e24146617ad48e80feca43 (diff)
downloadcpython-git-c4b8e05092b5aa018dd74f8563037b23d3c6756e.tar.gz
merge #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.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/cgitb.py b/Lib/cgitb.py
index e3ce2cb9d6..6eb52e764e 100644
--- a/Lib/cgitb.py
+++ b/Lib/cgitb.py
@@ -292,14 +292,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