[Django] #24399: Filesystem loaders should use more specific exceptions

9 views
Skip to first unread message

Django

unread,
Feb 23, 2015, 6:44:12 PM2/23/15
to django-...@googlegroups.com
#24399: Filesystem loaders should use more specific exceptions
--------------------------------------+--------------------
Reporter: prestontimmons | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
The `filesystem` and `app_directories` loaders use the following pattern
in `load_template_source`:

{{{
try:
...
except IOError:
pass
}}}

If no templates can be read, `TemplateDoesNotExist` is raised.

This isn't optimal because an `IOError` can be raised for many reasons
besides a file not existing, such as permission issues.

I think the file loaders should be updated to only catch the error if the
errno is `ENOENT`.

Jinja2 does a similar check, but it includes `EISDIR`. Theoretically, a
path could resolve to both a directory and a file. It seems like a weird
use case to catch, though.

--
Ticket URL: <https://code.djangoproject.com/ticket/24399>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 24, 2015, 9:04:50 AM2/24/15
to django-...@googlegroups.com
#24399: Filesystem loaders should use more specific exceptions
--------------------------------------+------------------------------------

Reporter: prestontimmons | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/24399#comment:1>

Django

unread,
Mar 2, 2015, 4:17:30 PM3/2/15
to django-...@googlegroups.com
#24399: Filesystem loaders should use more specific exceptions
--------------------------------------+------------------------------------

Reporter: prestontimmons | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by prestontimmons):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/24399#comment:2>

Django

unread,
Mar 2, 2015, 6:31:52 PM3/2/15
to django-...@googlegroups.com
#24399: Filesystem loaders should use more specific exceptions
-------------------------------------+-------------------------------------
Reporter: prestontimmons | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/24399#comment:3>

Django

unread,
Mar 3, 2015, 3:21:07 PM3/3/15
to django-...@googlegroups.com
#24399: Filesystem loaders should use more specific exceptions
-------------------------------------+-------------------------------------
Reporter: prestontimmons | Owner: nobody
Type: | Status: closed
Cleanup/optimization |

Component: Template system | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Aymeric Augustin <aymeric.augustin@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"70123cf084e3af7dfc61bb7bd2090ff802c3cda4"]:
{{{
#!CommitTicketReference repository=""
revision="70123cf084e3af7dfc61bb7bd2090ff802c3cda4"
Fixed #24399 -- Made filesystem loaders use more specific exceptions.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24399#comment:4>

Reply all
Reply to author
Forward
0 new messages