#15158 closed (fixed)
Server-crashing error: local variable 'loader_name' referenced before assignment
Reported by: | Gabriel Farrell | Owned by: | Ramiro Morales |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | regression | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Getting the following fatal crash traceback when visiting a page pointing at a missing template:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 282, in run
self.result = application(self.environ, self.start_response)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/staticfiles/handlers.py", line 74, in call
return self.application(environ, start_response)
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 273, in call
response = self.get_response(request)
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python2.6/dist-packages/django/views/debug.py", line 59, in technical_500_response
html = reporter.get_traceback_html()
File "/usr/local/lib/python2.6/dist-packages/django/views/debug.py", line 105, in get_traceback_html
'loader': loader_name,
UnboundLocalError: local variable 'loader_name' referenced before assignment
Attachments (1)
Change History (11)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Needs tests: | set |
---|
comment:3 by , 14 years ago
Keywords: | regression added |
---|---|
milestone: | → 1.3 |
Owner: | changed from | to
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
Oops, that was me in r15252. Thanks for the report.
follow-ups: 7 9 comment:4 by , 14 years ago
@gsf:
It seems one of the template loaders you have listed in your TEMPLATE_LOADERS
setting has problems when it is going to be loaded. Can you verify this and post the value of such setting?
comment:5 by , 14 years ago
Has patch: | set |
---|
comment:6 by , 14 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:7 by , 14 years ago
Replying to ramiro:
@gsf:
It seems one of the template loaders you have listed in your
TEMPLATE_LOADERS
setting has problems when it is going to be loaded. Can you verify this and post the value of such setting?
No, at that point the template loader loadability has already been verified in some other parts of the code (find_template
, find_template_loader
) so the exception isn't getting raised there. The problem is that the get_template_sources()
Loader method isn't part of the required API of a Loader, only the filesystem-based and app-dir loaders have it in the same way as the their counterpart old callable-based loaders pre-r11826 were the only having the get_template_sources()
function. The AttributeError is being raised at that point (possibly because the OP is using the egg loader or a third party loader.)
I'm going to fix this with the proposed patch that maintains the status quo. Users using loaders that don't implement Loader.get_template_sources()
won't get a list of templates tried in the debug error page just like happened with callable-based loader that didn't implement the get_template_sources()
function.
comment:8 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:9 by , 14 years ago
Replying to ramiro:
@gsf:
It seems one of the template loaders you have listed in your
TEMPLATE_LOADERS
setting has problems when it is going to be loaded. Can you verify this and post the value of such setting?
Sorry I missed this earlier. It looks like the error was caused by a combination of a missing template and the old style for template loaders in my settings file, i.e.:
TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', )
Sorry, here's the traceback preformatted: