summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorShai Berger <shai.berger@healarium.com>2013-05-18 19:26:34 +0300
committerShai Berger <shai.berger@healarium.com>2013-05-18 19:30:03 +0300
commitff881aef536640d712fd2bc53fa1ff98e300adad (patch)
tree9a1a2c7870e333118a544aae2c5bc69158b87768 /django
parent2c84f4434cd0f6e74471d5737b049c648cff538f (diff)
Fixed #13958 -- problem reporting exception from \r-line-ended file
Thanks petrvanblokland for reporting and saz for the patch
Diffstat (limited to 'django')
-rw-r--r--django/views/debug.py8
1 files changed, 4 insertions, 4 deletions
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