Changeset 1776 for pykota/trunk

Show
Ignore:
Timestamp:
10/05/04 11:41:13 (20 years ago)
Author:
jalet
Message:

Small fix for errors caused by unknown locale

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/tool.py

    r1766 r1776  
    2222# 
    2323# $Log$ 
     24# Revision 1.126  2004/10/05 09:41:13  jalet 
     25# Small fix for errors caused by unknown locale 
     26# 
    2427# Revision 1.125  2004/10/04 11:18:10  jalet 
    2528# Now exports the MD5 sum of the job's datas as an hexadecimal digest 
     
    513516        # Else we use the current locale's one. 
    514517        # If nothing is set, we use ISO-8859-15 widely used in western Europe. 
    515         self.charset = charset or os.environ.get("CHARSET") or locale.getlocale()[1] or locale.getdefaultlocale()[1] or "ISO-8859-15" 
     518        localecharset = locale.getlocale()[1] 
     519        try : 
     520            localecharset = localecharset or locale.getdefaultlocale()[1] 
     521        except ValueError :     
     522            pass        # Unknown locale, strange... 
     523        self.charset = charset or os.environ.get("CHARSET") or localecharset or "ISO-8859-15" 
    516524     
    517525        # pykota specific stuff