From ff881aef536640d712fd2bc53fa1ff98e300adad Mon Sep 17 00:00:00 2001 From: Shai Berger Date: Sat, 18 May 2013 19:26:34 +0300 Subject: Fixed #13958 -- problem reporting exception from \r-line-ended file Thanks petrvanblokland for reporting and saz for the patch --- django/views/debug.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'django') diff --git a/django/views/debug.py b/django/views/debug.py index 9b95b524d2..10c07e8f78 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -347,7 +347,7 @@ class ExceptionReporter(object): if source is None: try: with open(filename, 'rb') as fp: - source = fp.readlines() + source = fp.read().splitlines() except (OSError, IOError): pass if source is None: @@ -370,9 +370,9 @@ class ExceptionReporter(object): lower_bound = max(0, lineno - context_lines) upper_bound = lineno + context_lines - pre_context = [line.strip('\n') for line in source[lower_bound:lineno]] - context_line = source[lineno].strip('\n') - post_context = [line.strip('\n') for line in source[lineno+1:upper_bound]] + pre_context = source[lower_bound:lineno] + context_line = source[lineno] + post_context = source[lineno+1:upper_bound] return lower_bound, pre_context, context_line, post_context -- cgit v1.3