Commit 758123a1 authored by Karen Tracey's avatar Karen Tracey
Browse files

[1.1.X] Fixed #11461: Ensured complete traceback is available on the debug...

[1.1.X] 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. 

r12725 and r12726 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12727 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 9bdfe176
Loading
Loading
Loading
Loading
+1 −14
Original line number Diff line number Diff line
@@ -103,20 +103,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
+3 −2
Original line number Diff line number Diff line
@@ -75,10 +75,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):
+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ class Templates(unittest.TestCase):
        except TemplateSyntaxError, e:
            # Assert that we are getting the template syntax error and not the
            # string encoding error.
            self.assertEquals(e.args[0], "Caught an exception while rendering: Reverse for 'will_not_match' with arguments '()' and keyword arguments '{}' not found.")
            self.assertEquals(e.args[0], "Caught NoReverseMatch while rendering: Reverse for 'will_not_match' with arguments '()' and keyword arguments '{}' not found.")

        settings.SETTINGS_MODULE = old_settings_module
        settings.TEMPLATE_DEBUG = old_template_debug
+2 −0
Original line number Diff line number Diff line
{% load debugtags %}
{% go_boom arg %}
+0 −0

Empty file added.

Loading