Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.0.X] Fixed #10834 -- Added bucket condition to ensure that URL res…

…olvers won't ever return None. Thanks to Chris Cahoon for the patch.

Merge of r11120 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@11122 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 1153d4bf8003485461ea8194f938ee8a77c74364 1 parent c4e240f
@freakboy3742 freakboy3742 authored
View
1  django/core/urlresolvers.py
@@ -192,6 +192,7 @@ def resolve(self, path):
return sub_match[0], sub_match[1], sub_match_dict
tried.append(pattern.regex.pattern)
raise Resolver404, {'tried': tried, 'path': new_path}
+ raise Resolver404, {'tried': [], 'path' : path}
def _get_urlconf_module(self):
try:
View
18 tests/regressiontests/urlpatterns_reverse/tests.py
@@ -2,7 +2,9 @@
Unit tests for reverse URL lookups.
"""
-from django.core.urlresolvers import reverse, NoReverseMatch
+import unittest
+
+from django.core.urlresolvers import reverse, resolve, NoReverseMatch, Resolver404
from django.test import TestCase
test_data = (
@@ -96,3 +98,17 @@ def test_urlpattern_reverse(self):
else:
self.assertEquals(got, expected)
+class ResolverTests(unittest.TestCase):
+ def test_non_regex(self):
+ """
+ Verifies that we raise a Resolver404 if what we are resolving doesn't
+ meet the basic requirements of a path to match - i.e., at the very
+ least, it matches the root pattern '^/'. We must never return None
+ from resolve, or we will get a TypeError further down the line.
+
+ Regression for #10834.
+ """
+ self.assertRaises(Resolver404, resolve, '')
+ self.assertRaises(Resolver404, resolve, 'a')
+ self.assertRaises(Resolver404, resolve, '\\')
+ self.assertRaises(Resolver404, resolve, '.')
Please sign in to comment.
Something went wrong with that request. Please try again.