summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorLorenzo Peña <lorinkoz@gmail.com>2024-07-23 12:06:29 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-07-25 09:44:51 +0200
commit96a349740048ecd4746ac2f15751865219d445cf (patch)
treed37238f85da8c63deb8c7ea3eef5fa2e397cf0c5 /django/utils
parentc5d196a65264136ee6795356871a29f3d22ec52f (diff)
[4.2.x] Fixed #35627 -- Raised a LookupError rather than an unhandled ValueError in get_supported_language_variant().
LocaleMiddleware didn't handle the ValueError raised by get_supported_language_variant() when language codes were over 500 characters. Regression in 9e9792228a6bb5d6402a5d645bc3be4cf364aefb. Backport of 0e94f292cda632153f2b3d9a9037eb0141ae9c2e from main.
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/translation/trans_real.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index ce13d1e69c..6833b4bf7f 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -516,7 +516,7 @@ def get_supported_language_variant(lang_code, strict=False):
# There is a generic variant under the maximum length accepted length.
lang_code = lang_code[:index]
else:
- raise ValueError("'lang_code' exceeds the maximum accepted length")
+ raise LookupError(lang_code)
# If 'zh-hant-tw' is not supported, try special fallback or subsequent
# language codes i.e. 'zh-hant' and 'zh'.
possible_lang_codes = [lang_code]