Ticket #18229: 18229.diff

File 18229.diff, 2.9 KB (added by anubhav9042, 15 months ago)
  • django/views/debug.py

    diff --git a/django/views/debug.py b/django/views/debug.py
    index eb610b7..0d325ad 100644
    a b class ExceptionReporter(object): 
    427427
    428428        return lower_bound, pre_context, context_line, post_context
    429429
     430    def context_text(self, num, context):
     431        text = ""
     432        for item in context:
     433            text+=str(num)+". "+item+"\n"
     434            num+=1
     435
     436        return text
     437
    430438    def get_traceback_frames(self):
    431439        frames = []
    432440        tb = self.tb
    class ExceptionReporter(object): 
    442450            loader = tb.tb_frame.f_globals.get('__loader__')
    443451            module_name = tb.tb_frame.f_globals.get('__name__') or ''
    444452            pre_context_lineno, pre_context, context_line, post_context = self._get_lines_from_file(filename, lineno, 7, loader, module_name)
     453            pre_context_text = self.context_text(pre_context_lineno+1, pre_context)
     454            post_context_text = self.context_text(lineno+1, post_context)
     455            context_line+="\n"
    445456            if pre_context_lineno is not None:
    446457                frames.append({
    447458                    'tb': tb,
    class ExceptionReporter(object): 
    452463                    'vars': self.filter.get_traceback_frame_variables(self.request, tb.tb_frame),
    453464                    'id': id(tb),
    454465                    'pre_context': pre_context,
     466                    'pre_context_text': pre_context_text,
    455467                    'context_line': context_line,
    456468                    'post_context': post_context,
     469                    'post_context_text': post_context_text,
    457470                    'pre_context_lineno': pre_context_lineno + 1,
    458471                })
    459472            tb = tb.tb_next
    In template {{ template_info.name }}, error at line {{ template_info.line }} 
    10261039   {% endifequal %}{% endfor %}{% endif %}{% if frames %}
    10271040Traceback:
    10281041{% for frame in frames %}File "{{ frame.filename }}" in {{ frame.function }}
    1029 {% if frame.context_line %}  {{ frame.lineno }}. {{ frame.context_line }}{% endif %}
     1042{% if frame.pre_context_text and not is_email %}{{ frame.pre_context_text }}{% endif %}
     1043{% if frame.context_line %}{{ frame.lineno }}. {{ frame.context_line }}{% endif %}
     1044{% if frame.post_context_text and not is_email %}{{ frame.post_context_text }}{% endif %}
    10301045{% endfor %}
     1046{% if lastframe %}Exception Location: {{ lastframe.filename }} in {{ lastframe.function }}, line {{ lastframe.lineno }}{% endif %}
    10311047{% if exception_type %}Exception Type: {{ exception_type }}{% if request %} at {{ request.path_info }}{% endif %}
    10321048{% if exception_value %}Exception Value: {{ exception_value }}{% endif %}{% endif %}{% endif %}
     1049{% if unicode_hint %}Unicode Error Hint: {{ unicode_hint }}{% endif %}
    10331050{% if request %}Request information:
    10341051GET:{% for k, v in request.GET.items %}
    10351052{{ k }} = {{ v|stringformat:"r" }}{% empty %} No GET data{% endfor %}
Back to Top