#6423 closed (fixed)
technical_500_response fails on String Exceptions
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | 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 formated 500 response pages you get with DEBUG = True will fail if the error that is raised is a string, instead of of subclass of python's Exception.
This view:
def raise_string_view(request): raise 'String error!' return render_to_response('some_template.html', {})
will throw this exception:
Traceback (most recent call last): File "/usr/local/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 277, in run self.result = application(self.environ, self.start_response) File "/usr/local/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 631, in __call__ return self.application(environ, start_response) File "/usr/local/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 205, in __call__ response = self.get_response(request) File "/usr/local/lib/python2.5/site-packages/django/core/handlers/base.py", line 116, in get_response return debug.technical_500_response(request, *sys.exc_info()) File "/usr/local/lib/python2.5/site-packages/django/views/debug.py", line 77, in technical_500_response if issubclass(exc_type, TemplateDoesNotExist): TypeError: issubclass() arg 1 must be a class
Attachments (1)
Change History (9)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Yeah, that DeprecationWarning shows up in the server logs if you know to go looking for it, but the Traceback is very non-descriptive. I had to searching through the template system source to find out what was going on. If nothing else, we should improve the error message that is sent to the browser, so that developers know they have to get rid of their string-based exceptions.
comment:3 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
technical_500_response
shouldn't fail if at all possible. The fix shouldn't be too difficult.
comment:4 by , 17 years ago
Has patch: | set |
---|
comment:5 by , 17 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Thanks for the patch, guettli.
I can't decide if a test is needed for this change (or where it would go exactly). The code is clear, so I'll promote it and let a committer decide.
(PS: Try to stick to PEP8 - you should have spaces between your assignment "=" in code)
by , 17 years ago
Attachment: | views_debug_string_exceptions.diff added |
---|
Same diff, but with PEP8 coding style
String Exceptions are deprecated according to PEP 317
If everything is working correctly Python should be showing a deprecation error here:
I recommend a wontfix.