Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #10834 -- Added bucket condition to ensure that URL resolvers w…

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

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 735309341e24d53d5af41799a31aa964f424190c 1 parent e522e61
@freakboy3742 freakboy3742 authored
1  django/core/
@@ -195,6 +195,7 @@ def resolve(self, path):
return sub_match[0], sub_match[1], sub_match_dict
raise Resolver404, {'tried': tried, 'path': new_path}
+ raise Resolver404, {'tried': [], 'path' : path}
def _get_urlconf_module(self):
18 tests/regressiontests/urlpatterns_reverse/
@@ -14,8 +14,9 @@
ImproperlyConfigured: The included urlconf regressiontests.urlpatterns_reverse.no_urls doesn't have any patterns in it
+import unittest
-from django.core.urlresolvers import reverse, NoReverseMatch
+from django.core.urlresolvers import reverse, resolve, NoReverseMatch, Resolver404
from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect
from django.shortcuts import redirect
from django.test import TestCase
@@ -112,6 +113,21 @@ def test_urlpattern_reverse(self):
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, '.')
class ReverseShortcutTests(TestCase):
urls = 'regressiontests.urlpatterns_reverse.urls'

0 comments on commit 7353093

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