Code

Ticket #10216: 10216.diff

File 10216.diff, 1.2 KB (added by miracle2k, 5 years ago)
Line 
1diff --git a/django/views/debug.py b/django/views/debug.py
2index d1e9259..f9e373b 100644
3--- a/django/views/debug.py
4+++ b/django/views/debug.py
5@@ -4,7 +4,7 @@ import sys
6 import datetime
7 
8 from django.conf import settings
9-from django.template import Template, Context, TemplateDoesNotExist
10+from django.template import Template, Context, TemplateDoesNotExist, Origin
11 from django.utils.html import escape
12 from django.http import HttpResponse, HttpResponseServerError, HttpResponseNotFound
13 from django.utils.encoding import smart_unicode, smart_str
14@@ -78,8 +78,10 @@ class ExceptionReporter:
15                     'loader': loader.__module__ + '.' + loader.__name__,
16                     'templates': template_list,
17                 })
18-        if settings.TEMPLATE_DEBUG and hasattr(self.exc_value, 'source'):
19-            self.get_template_exception_info()
20+        if settings.TEMPLATE_DEBUG and hasattr(self.exc_value, 'source') and \
21+           isinstance(self.exc_value.source, (list, tuple)) and \
22+           len(self.exc_value.source)==2 and isinstance(self.exc_value[0], Origin):
23+                self.get_template_exception_info()
24 
25         frames = self.get_traceback_frames()
26