summaryrefslogtreecommitdiff
path: root/django/views/debug.py
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2019-10-09 00:00:57 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-11-12 11:31:12 +0100
commit4b78546ef19b93c02c60806c065e4560ee4fbee3 (patch)
treec17da0f8bcd32c813e75e788064f984df6b1d8cf /django/views/debug.py
parente8de188c06823ed5c574778dc1e47f035d7d0bf9 (diff)
downloaddjango-4b78546ef19b93c02c60806c065e4560ee4fbee3.tar.gz
Fixed #30405 -- Fixed source code mismatch crash in ExceptionReporter.
Diffstat (limited to 'django/views/debug.py')
-rw-r--r--django/views/debug.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/django/views/debug.py b/django/views/debug.py
index 58dc4de967..3b37e8da1a 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -384,10 +384,12 @@ class ExceptionReporter:
lower_bound = max(0, lineno - context_lines)
upper_bound = lineno + context_lines
- pre_context = source[lower_bound:lineno]
- context_line = source[lineno]
- post_context = source[lineno + 1:upper_bound]
-
+ try:
+ pre_context = source[lower_bound:lineno]
+ context_line = source[lineno]
+ post_context = source[lineno + 1:upper_bound]
+ except IndexError:
+ return None, [], None, []
return lower_bound, pre_context, context_line, post_context
def get_traceback_frames(self):