Ensure _locale is always set to a locale for which ICU has a collator

This commit is contained in:
Kovid Goyal 2022-04-24 14:18:26 +05:30
parent b6662c2650
commit 25f2a5827a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -72,7 +72,8 @@ def collator(strength=None, numeric=None, ignore_alternate_chars=None, upper_fir
ans = _icu.Collator(_locale)
except Exception as e:
print(f'Failed to load collator for locale: {_locale!r} with error {e!r}, using English', file=sys.stderr)
ans = _icu.Collator('en')
_locale = 'en'
ans = _icu.Collator(_locale)
else:
ans = collator().clone()
if strength is not None: