Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.2.X] Fixed #14027 -- Ensure that reverse() raises an exception whe…

…n you try to reverse None. Thanks to Alex for the report and patch.

Backport of r13499 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13500 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8419b092aeb9c28c3fe117c04c5d7d537aadaef2 1 parent 5bd352a
@freakboy3742 freakboy3742 authored
View
3  django/core/urlresolvers.py
@@ -183,7 +183,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
View
4 tests/regressiontests/urlpatterns_reverse/tests.py
@@ -119,6 +119,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):
"""

0 comments on commit 8419b09

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