From 971120778a7e7b7ebc2fc48275cca20a87580efe Mon Sep 17 00:00:00 2001 From: Alex Hill Date: Sun, 24 Jul 2016 22:00:39 +0800 Subject: [PATCH] Fixed #26945 -- Ensured that i18n_patterns returns a list --- django/conf/urls/i18n.py | 2 +- tests/i18n/tests.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/django/conf/urls/i18n.py b/django/conf/urls/i18n.py index 2813341a61..14f4c6971b 100644 --- a/django/conf/urls/i18n.py +++ b/django/conf/urls/i18n.py @@ -12,7 +12,7 @@ def i18n_patterns(*urls, **kwargs): URLconf. """ if not settings.USE_I18N: - return urls + return list(urls) prefix_default_language = kwargs.pop('prefix_default_language', True) assert not kwargs, 'Unexpected kwargs for i18n_patterns(): %s' % kwargs return [LocaleRegexURLResolver(list(urls), prefix_default_language=prefix_default_language)] diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index cbec5ee206..b6aeae8caa 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -1525,6 +1525,12 @@ class MiscTests(SimpleTestCase): with self.settings(LANGUAGES=[('en', 'English')]): self.assertNotEqual('pt-br', g(r)) + def test_i18n_patterns_returns_list(self): + with override_settings(USE_I18N=False): + self.assertIsInstance(i18n_patterns([]), list) + with override_settings(USE_I18N=True): + self.assertIsInstance(i18n_patterns([]), list) + class ResolutionOrderI18NTests(SimpleTestCase):