[Zope3-checkins] CVS: Zope3/src/zope/exceptions - exceptionformatter.py:1.4

Guido van Rossum guido@python.org
Mon, 21 Apr 2003 15:51:11 -0400


Update of /cvs-repository/Zope3/src/zope/exceptions
In directory cvs.zope.org:/tmp/cvs-serv8845

Modified Files:
	exceptionformatter.py 
Log Message:
Add the source line back to the traceback.  Now that tracebacks are no
longer shown on error pages (except when you turn on the specific
"debug" skin), but only in the ErrorLogging service or in the default
log file I don't think that showing the source code is a security
problem any more; and it's darn handy! :-)


=== Zope3/src/zope/exceptions/exceptionformatter.py 1.3 => 1.4 ===
--- Zope3/src/zope/exceptions/exceptionformatter.py:1.3	Thu Mar 13 13:34:06 2003
+++ Zope3/src/zope/exceptions/exceptionformatter.py	Mon Apr 21 15:51:10 2003
@@ -18,6 +18,7 @@
 """
 import sys
 import cgi
+import linecache
 
 DEBUG_EXCEPTION_FORMATTER = 1
 
@@ -129,6 +130,11 @@
 
         result = []
         result.append(self.escape(s))
+
+        # Append the source line, if available
+        line = linecache.getline(filename, lineno)
+        if line:
+            result.append("    " + self.escape(line.strip()))
 
         # Output a traceback supplement, if any.
         if '__traceback_supplement__' in locals: