From 70123cf084e3af7dfc61bb7bd2090ff802c3cda4 Mon Sep 17 00:00:00 2001 From: Preston Timmons Date: Mon, 2 Mar 2015 13:31:14 -0600 Subject: Fixed #24399 -- Made filesystem loaders use more specific exceptions. --- django/template/loaders/filesystem.py | 6 ++++-- django/views/debug.py | 4 ---- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'django') diff --git a/django/template/loaders/filesystem.py b/django/template/loaders/filesystem.py index cb61d576ed..74801efe56 100644 --- a/django/template/loaders/filesystem.py +++ b/django/template/loaders/filesystem.py @@ -2,6 +2,7 @@ Wrapper for loading templates from the filesystem. """ +import errno import io from django.core.exceptions import SuspiciousFileOperation @@ -37,6 +38,7 @@ class Loader(BaseLoader): try: with io.open(filepath, encoding=self.engine.file_charset) as fp: return fp.read(), filepath - except IOError: - pass + except IOError as e: + if e.errno != errno.ENOENT: + raise raise TemplateDoesNotExist(template_name) diff --git a/django/views/debug.py b/django/views/debug.py index 80b0e38eb1..15da162493 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -269,10 +269,6 @@ class ExceptionReporter(object): def format_path_status(self, path): if not os.path.exists(path): return "File does not exist" - if not os.path.isfile(path): - return "Not a file" - if not os.access(path, os.R_OK): - return "File is not readable" return "File exists" def get_traceback_data(self): -- cgit v1.3