schema cache: Fallback to 'en_us' when locale is not available

https://fedorahosted.org/freeipa/ticket/6204

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
David Kupka
2016-08-18 10:59:09 +02:00
committed by Jan Cholasta
parent 44a2bdd8ea
commit b6d5ed139b

View File

@@ -371,9 +371,15 @@ class Schema(object):
self._dict[ns] = {}
self._namespaces[ns] = _SchemaNameSpace(self, ns)
self._language = (
locale.setlocale(locale.LC_ALL, '').split('.')[0].lower()
)
# copy-paste from ipalib/rpc.py
try:
self._language = (
locale.setlocale(locale.LC_ALL, '').split('.')[0].lower()
)
except locale.Error:
# fallback to default locale
self._language = 'en_us'
try:
self._fingerprint = server_info['fingerprint']
self._expiration = server_info['expiration']