summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-10-27 18:42:36 (GMT)
committerR David Murray <rdmurray@bitdance.com>2012-10-27 18:42:36 (GMT)
commit54eed2e36d2c8e06ce1f1a30a3979587a3ac1af6 (patch)
tree494ca3af7d198ec9f1c277010f01dde7593f03e5
parent3e66f0d14d4541f85ee5daf00dbd3150a02fa4aa (diff)
downloadcpython-54eed2e36d2c8e06ce1f1a30a3979587a3ac1af6.zip
cpython-54eed2e36d2c8e06ce1f1a30a3979587a3ac1af6.tar.gz
cpython-54eed2e36d2c8e06ce1f1a30a3979587a3ac1af6.tar.bz2
#12890: don't emit <p> tags in text mode when logdir specified.
Patch by Jeff McNeil.
-rw-r--r--Lib/cgitb.py11
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
3 files changed, 12 insertions, 3 deletions
diff --git a/Lib/cgitb.py b/Lib/cgitb.py
index 5becdf3..8acc4b7 100644
--- a/Lib/cgitb.py
+++ b/Lib/cgitb.py
@@ -295,14 +295,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
diff --git a/Misc/ACKS b/Misc/ACKS
index ba6be3c..9211e63 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -644,6 +644,7 @@ Mark Mc Mahon
Gordon McMillan
Caolan McNamara
Andrew McNamara
+Jeff McNeil
Craig McPheeters
Lambert Meertens
Bill van Melle
diff --git a/Misc/NEWS b/Misc/NEWS
index 216346e..8df6477 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -122,6 +122,9 @@ Core and Builtins
Library
-------
+- Issue #12890: cgitb no longer prints spurious <p> tags in text
+ mode when the logdir option is specified.
+
- Issue #14398: Fix size truncation and overflow bugs in the bz2 module.
- Issue #5148: Ignore 'U' in mode given to gzip.open() and gzip.GzipFile().