Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #14027 -- Ensure that reverse() raises an exception when you tr…

…y to reverse None. Thanks to Alex for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13499 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f90a25551dbd10b7d57725a2abec3e11cf0e22cd 1 parent d3ba8cb
Russell Keith-Magee freakboy3742 authored
3  django/core/urlresolvers.py
View
@@ -217,7 +217,8 @@ def _populate(self):
else:
bits = normalize(p_pattern)
lookups.appendlist(pattern.callback, (bits, p_pattern))
- lookups.appendlist(pattern.name, (bits, p_pattern))
+ if pattern.name is not None:
+ lookups.appendlist(pattern.name, (bits, p_pattern))
self._reverse_dict = lookups
self._namespace_dict = namespaces
self._app_dict = apps
4 tests/regressiontests/urlpatterns_reverse/tests.py
View
@@ -154,6 +154,10 @@ def test_urlpattern_reverse(self):
else:
self.assertEquals(got, expected)
+ def test_reverse_none(self):
+ # Reversing None should raise an error, not return the last un-named view.
+ self.assertRaises(NoReverseMatch, reverse, None)
+
class ResolverTests(unittest.TestCase):
def test_non_regex(self):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.