Ticket #11461: template-dont-wrap-exception.diff

File template-dont-wrap-exception.diff, 2.2 KB (added by Glenn Maynard, 15 years ago)
  • django/template/debug.py

     
    6969    def render_node(self, node, context):
    7070        try:
    7171            result = node.render(context)
    72         except TemplateSyntaxError, e:
     72        except Exception, e:
    7373            if not hasattr(e, 'source'):
    7474                e.source = node.source
    7575            raise
    76         except Exception, e:
    77             from sys import exc_info
    78             wrapped = TemplateSyntaxError(u'Caught an exception while rendering: %s' % force_unicode(e, errors='replace'))
    79             wrapped.source = node.source
    80             wrapped.exc_info = exc_info()
    81             raise wrapped
    8276        return result
    8377
    8478class DebugVariableNode(VariableNode):
  • tests/regressiontests/templates/tests.py

     
    158158
    159159    def test_url_reverse_no_settings_module(self):
    160160        # Regression test for #9005
    161         from django.template import Template, Context, TemplateSyntaxError
     161        from django.template import Template, Context
     162        from django.core.urlresolvers import NoReverseMatch
    162163
    163164        old_settings_module = settings.SETTINGS_MODULE
    164165        old_template_debug = settings.TEMPLATE_DEBUG
     
    170171        c = Context()
    171172        try:
    172173            rendered = t.render(c)
    173         except TemplateSyntaxError, e:
     174        except NoReverseMatch, e:
    174175            # Assert that we are getting the template syntax error and not the
    175176            # string encoding error.
    176             self.assertEquals(e.args[0], "Caught an exception while rendering: Reverse for 'will_not_match' with arguments '()' and keyword arguments '{}' not found.")
     177            self.assertEquals(e.args[0], "Reverse for 'will_not_match' with arguments '()' and keyword arguments '{}' not found.")
    177178
    178179        settings.SETTINGS_MODULE = old_settings_module
    179180        settings.TEMPLATE_DEBUG = old_template_debug
Back to Top