Ignore unsupported locale setting and silently fall back to 'C'.
authorPascal Volk <neverseen@users.sourceforge.net>
Thu, 10 Sep 2009 01:42:26 +0000
changeset 152 3dbee02711cd
parent 151 350488efe67d
child 153 f0386ee0c7e8
Ignore unsupported locale setting and silently fall back to 'C'.
VirtualMailManager/__init__.py
--- a/VirtualMailManager/__init__.py	Wed Sep 09 07:13:20 2009 +0000
+++ b/VirtualMailManager/__init__.py	Thu Sep 10 01:42:26 2009 +0000
@@ -11,9 +11,12 @@
 from constants.VERSION import *
 import constants.ERROR as ERR
 
-# Set all of the locales according to the current environment variables
-# and get the character encoding.
-locale.setlocale(locale.LC_ALL, '')
+# Try to set all of the locales according to the current
+# environment variables and get the character encoding.
+try:
+    locale.setlocale(locale.LC_ALL, '')
+except locale.Error:
+    locale.setlocale(locale.LC_ALL, 'C')
 ENCODING = locale.nl_langinfo(locale.CODESET)
 
 def w_std(*args):