Opened 9 years ago

Closed 9 years ago

#26109 closed Cleanup/optimization (fixed)

loader.select_template() raises a confusing message if passed a string containing a period

Reported by: Ahmed Mohamed Owned by: nobody
Component: Template system Version: 1.9
Severity: Normal Keywords: template loader
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently supplying a string to select_template raise an IOError, which is not meaningful. Here's a sample.

IOError at XXX
[Errno 21] Is a directory: u'xxx/site-packages/django/contrib/admin/templates'

It's better to check if template_name_list is actually a list (Iterable). If it is a string, we can either

  • Raise a TypeError and suggest to use get_template function instead.
  • Pass the string to get_template silently.

I am creating a pull request going with the first option. Happy to change it if necessary.

Change History (4)

comment:1 by Tim Graham, 9 years ago

Easy pickings: unset
Has patch: set
Needs tests: set
Summary: Extra parameter check for loader.select_tamplate [Check if a string is passed].loader.select_tamplate() raises a confusing message if passed a string containing a period
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

PR (needs tests)

comment:2 by Tim Graham, 9 years ago

Summary: loader.select_tamplate() raises a confusing message if passed a string containing a periodloader.select_template() raises a confusing message if passed a string containing a period

comment:3 by Tim Graham, 9 years ago

Needs tests: unset

comment:4 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 229488c:

Fixed #26109 -- Raised a helpful error if loader.select_tamplate() is passed a string.

Note: See TracTickets for help on using tickets.
Back to Top