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/template/backends/base.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'django/template/backends') diff --git a/django/template/backends/base.py b/django/template/backends/base.py index 4156365b97..c47c95e51e 100644 --- a/django/template/backends/base.py +++ b/django/template/backends/base.py @@ -1,5 +1,3 @@ -from contextlib import suppress - from django.core.exceptions import ( ImproperlyConfigured, SuspiciousFileOperation, ) @@ -75,8 +73,9 @@ class BaseEngine: directory traversal attacks. """ for template_dir in self.template_dirs: - # SuspiciousFileOperation occurs if the jointed path is located - # outside of this template_dir (it might be inside another one, - # so this isn't fatal). - with suppress(SuspiciousFileOperation): + try: yield safe_join(template_dir, template_name) + except SuspiciousFileOperation: + # The joined path was located outside of this template_dir + # (it might be inside another one, so this isn't fatal). + pass -- cgit v1.3