Fixed #26280 -- Fixed cached template loader crash when loading nonexistent template.
This commit is contained in:
parent
eb44172760
commit
8890c533e0
|
@ -131,7 +131,7 @@ class Loader(BaseLoader):
|
||||||
template_tuple = self.template_cache.get(key)
|
template_tuple = self.template_cache.get(key)
|
||||||
# A cached previous failure:
|
# A cached previous failure:
|
||||||
if template_tuple is TemplateDoesNotExist:
|
if template_tuple is TemplateDoesNotExist:
|
||||||
raise TemplateDoesNotExist
|
raise TemplateDoesNotExist(template_name)
|
||||||
elif template_tuple is None:
|
elif template_tuple is None:
|
||||||
template, origin = self.find_template(template_name, template_dirs)
|
template, origin = self.find_template(template_name, template_dirs)
|
||||||
if not hasattr(template, 'render'):
|
if not hasattr(template, 'render'):
|
||||||
|
|
|
@ -46,3 +46,6 @@ Bugfixes
|
||||||
* Changed the admin's "permission denied" message in the login template to use
|
* Changed the admin's "permission denied" message in the login template to use
|
||||||
``get_username`` instead of ``username`` to support custom user models
|
``get_username`` instead of ``username`` to support custom user models
|
||||||
(:ticket:`26231`).
|
(:ticket:`26231`).
|
||||||
|
|
||||||
|
* Fixed a crash when passing a nonexistent template name to the cached template
|
||||||
|
loader's ``load_template()`` method (:ticket:`26280`).
|
||||||
|
|
|
@ -87,6 +87,18 @@ class CachedLoaderTests(SimpleTestCase):
|
||||||
"Cached loader failed to cache the TemplateDoesNotExist exception",
|
"Cached loader failed to cache the TemplateDoesNotExist exception",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ignore_warnings(category=RemovedInDjango20Warning)
|
||||||
|
def test_load_nonexistent_cached_template(self):
|
||||||
|
loader = self.engine.template_loaders[0]
|
||||||
|
template_name = 'nonexistent.html'
|
||||||
|
|
||||||
|
# fill the template cache
|
||||||
|
with self.assertRaises(TemplateDoesNotExist):
|
||||||
|
loader.find_template(template_name)
|
||||||
|
|
||||||
|
with self.assertRaisesMessage(TemplateDoesNotExist, template_name):
|
||||||
|
loader.get_template(template_name)
|
||||||
|
|
||||||
def test_templatedir_caching(self):
|
def test_templatedir_caching(self):
|
||||||
"""
|
"""
|
||||||
#13573 -- Template directories should be part of the cache key.
|
#13573 -- Template directories should be part of the cache key.
|
||||||
|
|
Loading…
Reference in New Issue