Ticket #14027: django-reverse-none.diff

File django-reverse-none.diff, 1.3 KB (added by Alex Gaynor, 14 years ago)
  • django/core/urlresolvers.py

    diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
    index cad57a5..8ecec94 100644
    a b class RegexURLResolver(object):  
    183183            else:
    184184                bits = normalize(p_pattern)
    185185                lookups.appendlist(pattern.callback, (bits, p_pattern))
    186                 lookups.appendlist(pattern.name, (bits, p_pattern))
     186                if pattern.name is not None:
     187                    lookups.appendlist(pattern.name, (bits, p_pattern))
    187188        self._reverse_dict = lookups
    188189        self._namespace_dict = namespaces
    189190        self._app_dict = apps
  • tests/regressiontests/urlpatterns_reverse/tests.py

    diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py
    index 3fcc935..98fc61f 100644
    a b class URLPatternReverse(TestCase):  
    118118                self.assertEqual(expected, NoReverseMatch)
    119119            else:
    120120                self.assertEquals(got, expected)
     121   
     122    def test_reverse_none(self):
     123        # Reversing None should raise an error, not return the last un-named
     124        # view.
     125        self.assertRaises(NoReverseMatch, reverse, None)
    121126
    122127class ResolverTests(unittest.TestCase):
    123128    def test_non_regex(self):
Back to Top