#12594 closed (fixed)
Meaningless exception when DEBUG=False and resolver.urlconf_module is None.
Reported by: | Yuri Baburov | Owned by: | Yuri Baburov |
---|---|---|---|
Component: | HTTP handling | Version: | 1.2-alpha |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Because of resolver.resolve500() can now fail due to urlconf_module set to None in django/core/handlers/base.py,
sometimes site developer doesn't get appropriate error message.
Instead developer gets message that handler500 is not found in urlconf module.
Problem is only in handler500 lookup, everything else goes well.
How to reproduce:
set DEBUG to False, comment out ROOT_URLCONF line.
I managed to find this problem it another way, but it will take some time to figure out how settings.py can be imported without errors, but get empty dir to LazySettings.
My suggested fix:
def handle_uncaught_exception(self, request, resolver, exc_info): ... mail_admins(subject, message, fail_silently=True) # Return an HttpResponse that displays a friendly error message. if resolver.urlconf_module is None: # FIX LINE1: you aren't getting http500! raise exc_info[1], None, exc_info[2] # FIX LINE2: so we'll raise it raw. callback, param_dict = resolver.resolve500() return callback(request, **param_dict)
Attachments (1)
Change History (11)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
I've met similar problems, when I got some internal error (I can give you further info if it's relevant) and django tried to display error page 500.
This problem occours *only* when settings.DEBUG is False.
When DEBUG is True I see helpful error page about actual error that have occoured, not error in error displaying :-)
Here you got Traceback, when DEBUG is FALSE:
Traceback (most recent call last): File "/srv/trunk/external-packages/django/core/servers/basehttp.py", line 280, in run self.result = application(self.environ, self.start_response) File "/srv/trunk/external-packages/django/core/servers/basehttp.py", line 672, in __call__ return self.application(environ, start_response) File "/srv/trunk/external-packages/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) File "/srv/trunk/external-packages/django/core/handlers/base.py", line 143, in get_response return self.handle_uncaught_exception(request, resolver, exc_info) File "/srv/trunk/external-packages/django/core/handlers/base.py", line 178, in handle_uncaught_exception callback, param_dict = resolver.resolve500() File "/srv/trunk/external-packages/django/core/urlresolvers.py", line 268, in resolve500 return self._resolve_special('500') File "/srv/trunk/external-packages/django/core/urlresolvers.py", line 258, in _resolve_special callback = getattr(self.urlconf_module, 'handler%s' % view_type) AttributeError: 'NoneType' object has no attribute 'handler500'
This message says nothing about actual error.
comment:3 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 15 years ago
Has patch: | unset |
---|---|
Needs tests: | set |
Please attach a patch that is a diff, not an inline display of a complete routine.
comment:5 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I attached complete routine exactly because I wanted someone to write the patch and check me, I'm not sure in all python versions my re-raising exception works correctly.
Ok, going to attach test & patch tomorrow.
comment:7 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Exception Before:
Exception after: