diff options
| author | Tim Graham <timograham@gmail.com> | 2017-09-07 08:16:21 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-09-07 08:16:21 -0400 |
| commit | 6e4c6281dbb7ee12bcdc22620894edb4e9cf623f (patch) | |
| tree | 1c21218d4b6f00c499f18943d5190ebe7b5248c9 /django/views/debug.py | |
| parent | 8b2515a450ef376b9205029090af0a79c8341bd7 (diff) | |
Reverted "Fixed #27818 -- Replaced try/except/pass with contextlib.suppress()."
This reverts commit 550cb3a365dee4edfdd1563224d5304de2a57fda
because try/except performs better.
Diffstat (limited to 'django/views/debug.py')
| -rw-r--r-- | django/views/debug.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/django/views/debug.py b/django/views/debug.py index 35cff6338f..a0af0c96f4 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -2,7 +2,6 @@ import functools import re import sys import types -from contextlib import suppress from pathlib import Path from django.conf import settings @@ -348,14 +347,18 @@ class ExceptionReporter: """ source = None if loader is not None and hasattr(loader, "get_source"): - with suppress(ImportError): + try: source = loader.get_source(module_name) + except ImportError: + pass if source is not None: source = source.splitlines() if source is None: - with suppress(OSError, IOError): + try: with open(filename, 'rb') as fp: source = fp.read().splitlines() + except (OSError, IOError): + pass if source is None: return None, [], None, [] |
