From 57eb17b8c7d106c9a3264aa35b8dabb179a1e17b Mon Sep 17 00:00:00 2001 From: Vytis Banaitis Date: Mon, 13 Jun 2016 14:58:25 +0300 Subject: [PATCH] Fixed #26746 -- Fixed handling of zero priority in Accept-Language header parsing. --- django/utils/translation/trans_real.py | 2 +- tests/i18n/tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index 2f205be46d..4387ec5a36 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -791,7 +791,7 @@ def parse_accept_lang_header(lang_string): return [] if priority: priority = float(priority) - if not priority: # if priority is 0.0 at this point make it 1.0 + else: priority = 1.0 result.append((lang, priority)) result.sort(key=lambda k: k[1], reverse=True) diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index c6a08323fe..6875de547c 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -1315,7 +1315,7 @@ class MiscTests(SimpleTestCase): p('de,en-au;q=0.75,en-us;q=0.5,en;q=0.25,es;q=0.125,fa;q=0.125') ) self.assertEqual([('*', 1.0)], p('*')) - self.assertEqual([('de', 1.0)], p('de;q=0.')) + self.assertEqual([('de', 0.0)], p('de;q=0.')) self.assertEqual([('en', 1.0), ('*', 0.5)], p('en; q=1.0, * ; q=0.5')) self.assertEqual([('en', 1.0)], p('en; q=1,')) self.assertEqual([], p(''))