From 252cd0e4e0b11c7d13e24146617ad48e80feca43 Mon Sep 17 00:00:00 2001 From: R David Murray Date: Sat, 27 Oct 2012 14:42:47 -0400 Subject: #12890: don't emit

tags in text mode when logdir specified. Patch by Jeff McNeil. --- Lib/cgitb.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'Lib/cgitb.py') diff --git a/Lib/cgitb.py b/Lib/cgitb.py index 7b52c8e74c..6da40e82ec 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 = '

%s contains the description of this error.' % path + msg = '%s contains the description of this error.' % path except: - msg = '

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('

%s

\n' % msg) + else: + self.file.write(msg + '\n') try: self.file.flush() except: pass -- cgit v1.2.1