mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #11461: Ensured complete traceback is available on the debug page when an exception is encountered during template rendering, even when running on Python 2.6 or higher. Thanks Glenn.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12725 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -104,20 +104,7 @@ builtins = []
|
||||
invalid_var_format_string = None
|
||||
|
||||
class TemplateSyntaxError(Exception):
|
||||
def __str__(self):
|
||||
try:
|
||||
import cStringIO as StringIO
|
||||
except ImportError:
|
||||
import StringIO
|
||||
output = StringIO.StringIO()
|
||||
output.write(Exception.__str__(self))
|
||||
# Check if we wrapped an exception and print that too.
|
||||
if hasattr(self, 'exc_info'):
|
||||
import traceback
|
||||
output.write('\n\nOriginal ')
|
||||
e = self.exc_info
|
||||
traceback.print_exception(e[0], e[1], e[2], 500, output)
|
||||
return output.getvalue()
|
||||
pass
|
||||
|
||||
class TemplateDoesNotExist(Exception):
|
||||
pass
|
||||
|
||||
@@ -76,10 +76,11 @@ class DebugNodeList(NodeList):
|
||||
raise
|
||||
except Exception, e:
|
||||
from sys import exc_info
|
||||
wrapped = TemplateSyntaxError(u'Caught an exception while rendering: %s' % force_unicode(e, errors='replace'))
|
||||
wrapped = TemplateSyntaxError(u'Caught %s while rendering: %s' %
|
||||
(e.__class__.__name__, force_unicode(e, errors='replace')))
|
||||
wrapped.source = node.source
|
||||
wrapped.exc_info = exc_info()
|
||||
raise wrapped
|
||||
raise wrapped, None, wrapped.exc_info[2]
|
||||
return result
|
||||
|
||||
class DebugVariableNode(VariableNode):
|
||||
|
||||
Reference in New Issue
Block a user