﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1647	django/core/template/__init__.py destroys useful information about exception	alankila	Adrian Holovaty	"The DebugNodeList hides useful information about the exception that occured.
{{{
class DebugNodeList(NodeList):
    def render_node(self, node, context):
        try:
            result = node.render(context)
        except TemplateSyntaxError, e:
            if not hasattr(e, 'source'):
                e.source = node.source
            raise
        except Exception:
            from sys import exc_info
            wrapped = TemplateSyntaxError('Caught an exception while rendering.')
            wrapped.source = node.source
            wrapped.exc_info = exc_info()
            raise wrapped
        return result
}}}
I propose changing it like this:
{{{
class DebugNodeList(NodeList):
    def render_node(self, node, context):
        try:
            result = node.render(context)
        except TemplateSyntaxError, e:
            if not hasattr(e, 'source'):
                e.source = node.source
            raise
        except Exception e:
            from sys import exc_info
            wrapped = TemplateSyntaxError('Caught an exception while rendering: %s' % e)
            wrapped.source = node.source
            wrapped.exc_info = exc_info()
            raise wrapped
        return result
}}}
I had a bug that caused the stock 500 handler to fail to work. The change makes the difference of debuggability between the errors:
{{{
TemplateSyntaxError: Caught an exception while rendering.
}}}
and
{{{
TemplateSyntaxError: Caught an exception while rendering: 'Attachment' object has no attribute 'message'.
}}}
After this change, I was able to make admin work again. It appears that my model's repr function had hit a problem or limitation with Django. (Separate ticket about the limitation follows.)"	defect	closed	contrib.admin		normal	fixed			Unreviewed	0	0	0	0	0	0
