mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[5.0.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 in9e9792228a. Backport of0e94f292cdfrom main.
This commit is contained in:
committed by
Sarah Boyce
parent
41d8ef18ac
commit
e18601273a
@@ -517,7 +517,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]
|
||||
|
||||
Reference in New Issue
Block a user