Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.1.X] Fixed #12083: Ensured generating debug 404 page won't raise a…

… key error. Thanks pigletto.

r12679 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12680 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b5a2f64cbba38cb0ff814118b0abbee05253db58 1 parent 1fedc0b
@kmtracey kmtracey authored
View
2  django/views/debug.py
@@ -245,7 +245,7 @@ def technical_404_response(request, exception):
"Create a technical 404 error response. The exception should be the Http404."
try:
tried = exception.args[0]['tried']
- except (IndexError, TypeError):
+ except (IndexError, TypeError, KeyError):
tried = []
else:
if not tried:
View
4 tests/regressiontests/views/tests/debug.py
@@ -19,3 +19,7 @@ def test_files(self):
response = self.client.post('/views/raises/', data)
self.failUnless('file_data.txt' in response.content)
self.failIf('haha' in response.content)
+
+ def test_404(self):
+ response = self.client.get('/views/raises404/')
+ self.assertEquals(response.status_code, 404)
View
3  tests/regressiontests/views/urls.py
@@ -95,7 +95,8 @@
# a view that raises an exception for the debug view
urlpatterns += patterns('',
- (r'^raises/$', views.raises)
+ (r'^raises/$', views.raises),
+ (r'^raises404/$', views.raises404),
)
# rediriects, both temporary and permanent, with non-ASCII targets
View
6 tests/regressiontests/views/views.py
@@ -4,6 +4,7 @@
from django import forms
from django.views.debug import technical_500_response
from django.views.generic.create_update import create_object
+from django.core.urlresolvers import get_resolver
from models import Article
@@ -12,7 +13,6 @@ def index_page(request):
"""Dummy index page"""
return HttpResponse('<html><body>Dummy page</body></html>')
-
def custom_create(request):
"""
Calls create_object generic view with a custom form class.
@@ -37,6 +37,10 @@ def raises(request):
except Exception:
return technical_500_response(request, *sys.exc_info())
+def raises404(request):
+ resolver = get_resolver(None)
+ resolver.resolve('')
+
def redirect(request):
"""
Forces an HTTP redirect.

0 comments on commit b5a2f64

Please sign in to comment.
Something went wrong with that request. Please try again.