mirror of
https://github.com/django/django.git
synced 2025-11-14 09:17:36 +00:00
Fixed #24399 -- Made filesystem loaders use more specific exceptions.
This commit is contained in:
parent
85757d0e79
commit
70123cf084
5 changed files with 50 additions and 43 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue