summaryrefslogtreecommitdiff
path: root/django/template/backends
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-09-07 08:16:21 -0400
committerGitHub <noreply@github.com>2017-09-07 08:16:21 -0400
commit6e4c6281dbb7ee12bcdc22620894edb4e9cf623f (patch)
tree1c21218d4b6f00c499f18943d5190ebe7b5248c9 /django/template/backends
parent8b2515a450ef376b9205029090af0a79c8341bd7 (diff)
Reverted "Fixed #27818 -- Replaced try/except/pass with contextlib.suppress()."
This reverts commit 550cb3a365dee4edfdd1563224d5304de2a57fda because try/except performs better.
Diffstat (limited to 'django/template/backends')
-rw-r--r--django/template/backends/base.py11
1 files changed, 5 insertions, 6 deletions
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