Fallback to default locale (en_US) if env. setting is corrupt.

This commit is contained in:
Pavel Zuna authored and Rob Crittenden committed 2011-03-01 10:31:37 -05:00
1 parent bfca99b420
commit bbc94034b0
1 file changed
+5 -1
+5 -1
View File
@@ -196,7 +196,11 @@ class LanguageAwareTransport(Transport):
def get_host_info(self, host):
(host, extra_headers, x509) = Transport.get_host_info(self, host)
lang = locale.setlocale(locale.LC_ALL, '').split('.')[0].lower()
try:
lang = locale.setlocale(locale.LC_ALL, '').split('.')[0].lower()
except locale.Error:
# fallback to default locale
lang = 'en_us'
if not isinstance(extra_headers, list):
extra_headers = []