From 6e4c6281dbb7ee12bcdc22620894edb4e9cf623f Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 7 Sep 2017 08:16:21 -0400 Subject: Reverted "Fixed #27818 -- Replaced try/except/pass with contextlib.suppress()." This reverts commit 550cb3a365dee4edfdd1563224d5304de2a57fda because try/except performs better. --- django/views/debug.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'django/views/debug.py') 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, [] -- cgit v1.3