From 83e52e316225650467ebbee2d86eff7bd5b566e7 Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Wed, 24 Feb 2010 21:58:01 +0000 Subject: [PATCH] Fixed #10216. Only try to gather template exception info if the exception is a Django TemplateSyntaxError. Thanks, Alex Gaynor. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12586 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/views/debug.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/django/views/debug.py b/django/views/debug.py index 6312d01c07..e4e23f2563 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -1,15 +1,17 @@ +import datetime import os import re import sys -import datetime from django.conf import settings -from django.template import Template, Context, TemplateDoesNotExist +from django.http import HttpResponse, HttpResponseServerError, HttpResponseNotFound +from django.template import (Template, Context, TemplateDoesNotExist, + TemplateSyntaxError) from django.utils.html import escape from django.utils.importlib import import_module -from django.http import HttpResponse, HttpResponseServerError, HttpResponseNotFound from django.utils.encoding import smart_unicode, smart_str + HIDDEN_SETTINGS = re.compile('SECRET|PASSWORD|PROFANITIES_LIST') def linebreak_iter(template_source): @@ -100,7 +102,8 @@ class ExceptionReporter: 'loader': loader_name, 'templates': template_list, }) - if settings.TEMPLATE_DEBUG and hasattr(self.exc_value, 'source'): + if (settings.TEMPLATE_DEBUG and hasattr(self.exc_value, 'source') and + isinstance(self.exc_value, TemplateSyntaxError)): self.get_template_exception_info() frames = self.get_traceback_frames()