Fixed #23522 -- Changed reverse() to return a Unicode string; not bytes
This commit is contained in:
parent
d1e87aebf7
commit
c1ef234e31
|
@ -577,9 +577,9 @@ def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None, current
|
|||
if ns_pattern:
|
||||
resolver = get_ns_resolver(ns_pattern, resolver)
|
||||
|
||||
return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
|
||||
return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
|
||||
|
||||
reverse_lazy = lazy(reverse, str)
|
||||
reverse_lazy = lazy(reverse, six.text_type)
|
||||
|
||||
|
||||
def clear_url_caches():
|
||||
|
|
|
@ -607,6 +607,10 @@ Miscellaneous
|
|||
* The default max size of the Oracle test tablespace has increased from 200M
|
||||
to 500M.
|
||||
|
||||
* :func:`~django.core.urlresolvers.reverse` and
|
||||
:func:`~django.core.urlresolvers.reverse_lazy` now return Unicode strings
|
||||
instead of byte strings.
|
||||
|
||||
.. _deprecated-features-1.8:
|
||||
|
||||
Features deprecated in 1.8
|
||||
|
|
|
@ -222,6 +222,13 @@ class URLPatternReverse(TestCase):
|
|||
# exception
|
||||
self.fail("Expected a NoReverseMatch, but none occurred.")
|
||||
|
||||
def test_reverse_returns_unicode(self):
|
||||
name, expected, args, kwargs = test_data[0]
|
||||
self.assertIsInstance(
|
||||
reverse(name, args=args, kwargs=kwargs),
|
||||
six.text_type
|
||||
)
|
||||
|
||||
|
||||
class ResolverTests(unittest.TestCase):
|
||||
def test_resolver_repr(self):
|
||||
|
|
Loading…
Reference in New Issue