From 885dd85b5f7f35cf3266c6552d77f5577bb66828 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 6 May 2006 23:18:22 +0000 Subject: [PATCH] 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 --- django/views/debug.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/django/views/debug.py b/django/views/debug.py index 6d1b0d0e6c..16cf937d80 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -96,18 +96,19 @@ def technical_500_response(request, exc_type, exc_value, tb): function = tb.tb_frame.f_code.co_name lineno = tb.tb_lineno - 1 pre_context_lineno, pre_context, context_line, post_context = _get_lines_from_file(filename, lineno, 7) - frames.append({ - 'tb': tb, - 'filename': filename, - 'function': function, - 'lineno': lineno + 1, - 'vars': tb.tb_frame.f_locals.items(), - 'id': id(tb), - 'pre_context': pre_context, - 'context_line': context_line, - 'post_context': post_context, - 'pre_context_lineno': pre_context_lineno + 1, - }) + if pre_context_lineno: + frames.append({ + 'tb': tb, + 'filename': filename, + 'function': function, + 'lineno': lineno + 1, + 'vars': tb.tb_frame.f_locals.items(), + 'id': id(tb), + 'pre_context': pre_context, + 'context_line': context_line, + 'post_context': post_context, + 'pre_context_lineno': pre_context_lineno + 1, + }) tb = tb.tb_next t = Template(TECHNICAL_500_TEMPLATE)