Fixed #1785 -- debug view no longer assumes _get_lines_from_file returns None. Thanks, django@binaryfeed.org

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2864 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-05-06 23:18:22 +00:00
parent be0032f5ba
commit 885dd85b5f
1 changed files with 13 additions and 12 deletions

View File

@ -96,18 +96,19 @@ def technical_500_response(request, exc_type, exc_value, tb):
function = tb.tb_frame.f_code.co_name function = tb.tb_frame.f_code.co_name
lineno = tb.tb_lineno - 1 lineno = tb.tb_lineno - 1
pre_context_lineno, pre_context, context_line, post_context = _get_lines_from_file(filename, lineno, 7) pre_context_lineno, pre_context, context_line, post_context = _get_lines_from_file(filename, lineno, 7)
frames.append({ if pre_context_lineno:
'tb': tb, frames.append({
'filename': filename, 'tb': tb,
'function': function, 'filename': filename,
'lineno': lineno + 1, 'function': function,
'vars': tb.tb_frame.f_locals.items(), 'lineno': lineno + 1,
'id': id(tb), 'vars': tb.tb_frame.f_locals.items(),
'pre_context': pre_context, 'id': id(tb),
'context_line': context_line, 'pre_context': pre_context,
'post_context': post_context, 'context_line': context_line,
'pre_context_lineno': pre_context_lineno + 1, 'post_context': post_context,
}) 'pre_context_lineno': pre_context_lineno + 1,
})
tb = tb.tb_next tb = tb.tb_next
t = Template(TECHNICAL_500_TEMPLATE) t = Template(TECHNICAL_500_TEMPLATE)