locale on cygwin

Andy Todd andy47 at halfcooked.com
Fri Feb 1 04:31:43 EST 2002


Jason Tishler wrote:

> Andy,
> 
> On Fri, Jan 25, 2002 at 05:22:02AM +0000, Andy Todd wrote:
> 
>>Jason Tishler probably knows the answer to this off the top of his head,
>>but ... 
>>
> 
> Not really, being locale challenged...
> 
> 
>>I'm having problems getting 'locale' to work with Python under cygwin.
>>
>>[snip]
>>
>>But on the same machine with Cygwin python I get;
>>
>>Python 2.2 (#1, Dec 31 2001, 15:21:18)
>>[GCC 2.95.3-5 (cygwin special)] on cygwin
>>Type "help", "copyright", "credits" or "license" for more information.
>>
>>>>>import locale
>>>>>locale.getdefaultlocale()
>>>>>
>>(None, None)
>>
>>>>>locale.setlocale(locale.LC_ALL, '')
>>>>>
>>'C'
>>
>>I presume this means that the _locale module is not present on Cygwin, or
>>compiled in with Python.
>>
> 
> No, it's there:
> 
>     /usr/lib/python2.2/lib-dynload/_locale.dll
> 
> but...
> 
> 
>>Is there any particular reason why? 
>>
> 
> Yes, IIRC, Cygwin does not currently support locale.  Searching the
> Cygwin mailing list I have found the following:
> 
>     http://sources.redhat.com/ml/cygwin/2001-11/msg00458.html
> 
> Which seems to concur.  Sorry, this is the best that I can do.  Maybe
> others know for sure.
> 
> Jason
> 
> 
> 

Thanks for the input Jason, but the plot thickens ;-)

I've expanded my research to Linux and am getting some funny results 
there. I've got Python 2.1.1 on Debian testing (2.2) and with KDE 
everything is hunky dory;

"""
angua:/home/andy47# python
Python 2.1.1+ (#1, Jan  8 2002, 00:37:12)
[GCC 2.95.4 20011006 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
 >>> import locale
 >>> dir(locale)
['CHAR_MAX', 'Error', 'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MESSAGES', 
'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', '__all__', '__builtins__', 
'__doc__', '__file__', '__name__', '_build_localename', '_group', 
'_parse_localename', '_print_locale', '_setlocale', '_test', 'atof', 
'atoi', 'encoding_alias', 'format', 'getdefaultlocale', 'getlocale', 
'locale_alias', 'localeconv', 'normalize', 'resetlocale', 'setlocale', 
'str', 'strcoll', 'strxfrm', 'sys', 'windows_locale']
 >>> locale.LC_ALL
6
 >>> locale.setlocale(locale.LC_ALL, '')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/usr/lib/python2.1/locale.py", line 374, in setlocale
     return _setlocale(category, locale)
locale.Error: locale setting not supported
 >>>
angua:/home/andy47# echo $LANG
en_AU
angua:/home/andy47#
"""

But with gnome I get very similar results to Cygwin;

"""
angua:/home/andy47# python
Python 2.1.1+ (#1, Jan  8 2002, 00:37:12)
[GCC 2.95.4 20011006 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
 >>> import locale
 >>> dir(locale)
['CHAR_MAX', 'Error', 'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MESSAGES', 
'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', '__all__', '__builtins__', 
'__doc__', '__file__', '__name__', '_build_localename', '_group', 
'_parse_localename', '_print_locale', '_setlocale', '_test', 'atof', 
'atoi', 'encoding_alias', 'format', 'getdefaultlocale', 'getlocale', 
'locale_alias', 'localeconv', 'normalize', 'resetlocale', 'setlocale', 
'str', 'strcoll', 'strxfrm', 'sys', 'windows_locale']
 >>> locale.LC_ALL
6
 >>> locale.setlocale(locale.LC_ALL, '')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/usr/lib/python2.1/locale.py", line 374, in setlocale
     return _setlocale(category, locale)
locale.Error: locale setting not supported
 >>>
angua:/home/andy47# echo $LANG
en_AU
angua:/home/andy47#
"""

I'm still confused, and the exception raised by Gnome is causing me a 
right pain. Anyone else like to chip in?

Regards,
Andy
-- 
-----------------------------------------------------------------------
 From the desk of Andrew J Todd esq.
"Another year older, still no wiser." - Me, on my birthday





More information about the Python-list mailing list