Opened 11 years ago
Closed 11 years ago
#24399 closed Cleanup/optimization (fixed)
Filesystem loaders should use more specific exceptions
| Reported by: | Preston Timmons | Owned by: | nobody |
|---|---|---|---|
| Component: | Template system | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (4)
comment:1 by , 11 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 11 years ago
| Has patch: | set |
|---|
comment:3 by , 11 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:4 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
In 70123cf084e3af7dfc61bb7bd2090ff802c3cda4: