[Checkins] SVN: zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/exceptionformatter.py Cleanups.

Tres Seaver cvs-admin at zope.org
Fri Apr 6 19:36:17 UTC 2012


Log message for revision 125018:
  Cleanups.
  
  Remove 'show_revisions' fossil.
  
  Factor out HTML-specific bits from TextExceptionFormatter's 'formatSupplement'
  into new 'formatSupplementInfo' method, overridden by HTMLExceptionFormatter.
  
  Mark non-coverable junk.
  

Changed:
  U   zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/exceptionformatter.py

-=-
Modified: zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/exceptionformatter.py
===================================================================
--- zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/exceptionformatter.py	2012-04-06 19:36:10 UTC (rev 125017)
+++ zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/exceptionformatter.py	2012-04-06 19:36:14 UTC (rev 125018)
@@ -25,7 +25,6 @@
 class TextExceptionFormatter(object):
 
     line_sep = '\n'
-    show_revisions = 0
 
     def __init__(self, limit=None, with_filenames=False):
         self.limit = limit
@@ -84,17 +83,16 @@
             try:
                 extra = getInfo()
                 if extra:
-                    extra = self.escape(extra)
-                    if self.line_sep != "\n":
-                        extra = extra.replace(" ", " ")
-                        extra = extra.replace("\n", self.line_sep)
-                    result.append(extra)
-            except:
+                    result.append(self.formatSupplementInfo(extra))
+            except: #pragma NO COVER
                 if DEBUG_EXCEPTION_FORMATTER:
                     traceback.print_exc()
                 # else just swallow the exception.
         return result
 
+    def formatSupplementInfo(self, info):
+        return self.escape(info)
+
     def formatTracebackInfo(self, tbi):
         return self.formatSupplementLine('__traceback_info__: %s' % (tbi, ))
 
@@ -109,9 +107,10 @@
         co = f.f_code
         filename = co.co_filename
         name = co.co_name
-        locals = f.f_locals
-        globals = f.f_globals
+        locals = f.f_locals    # XXX shadowing normal builtins deliberately?
+        globals = f.f_globals  # XXX shadowing normal builtins deliberately?
 
+
         if self.with_filenames:
             s = '  File "%s", line %d' % (filename, lineno)
         else:
@@ -144,7 +143,7 @@
             try:
                 supp = factory(*args)
                 result.extend(self.formatSupplement(supp, tb))
-            except:
+            except: #pragma NO COVER
                 if DEBUG_EXCEPTION_FORMATTER:
                     traceback.print_exc()
                 # else just swallow the exception.
@@ -153,7 +152,7 @@
             tbi = locals.get('__traceback_info__', None)
             if tbi is not None:
                 result.append(self.formatTracebackInfo(tbi))
-        except:
+        except: #pragma NO COVER
             if DEBUG_EXCEPTION_FORMATTER:
                 traceback.print_exc()
             # else just swallow the exception.
@@ -222,6 +221,12 @@
     def formatSupplementLine(self, line):
         return '<b>%s</b>' % self.escape(str(line))
 
+    def formatSupplementInfo(self, info):
+        info = self.escape(info)
+        info = info.replace(" ", "&nbsp;")
+        info = info.replace("\n", self.line_sep)
+        return info
+
     def formatTracebackInfo(self, tbi):
         s = self.escape(str(tbi))
         s = s.replace('\n', self.line_sep)



More information about the checkins mailing list