]> granicus.if.org Git - python/commitdiff
#12890: don't emit <p> tags in text mode when logdir specified.
authorR David Murray <rdmurray@bitdance.com>
Sat, 27 Oct 2012 18:42:36 +0000 (14:42 -0400)
committerR David Murray <rdmurray@bitdance.com>
Sat, 27 Oct 2012 18:42:36 +0000 (14:42 -0400)
Patch by Jeff McNeil.

Lib/cgitb.py
Misc/ACKS
Misc/NEWS

index 5becdf365322322e2270037432c928781edf91fb..8acc4b75fe3b384c144ed14c23626188948612e4 100644 (file)
@@ -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
index ba6be3ca68db188899de0d3d5bc749c9900990fe..9211e637f3f6245abe8bb9dc25a1d45f3031fd8c 100644 (file)
--- 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
index 216346e4a43d743b21dea0dd0c499c1874ccd477..8df6477c401c20dcdf693d556ef41ca50ac119dc 100644 (file)
--- 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().