Title: unknown locale de_DE@euro on Suse 8.0 Linux
Type: Stage:
Components: Library (Lib) Versions: Python 2.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: loewis Nosy List: chemacortes, groovehunter, loewis, nnorwitz, vinweh
Priority: normal Keywords:

Created on 2002-05-10 21:02 by vinweh, last changed 2003-03-02 11:45 by loewis. This issue is now closed.

Messages (9)
msg10715 - (view) Author: vincent wehren (vinweh) Date: 2002-05-10 21:02
Python 2.2 (#1, Mar 26 2002, 15:46:04)   
[GCC 2.95.3 20010315 (SuSE)] on linux2   
When calling the locale module's getdefaultlocale() 
method on SuSe 8.0 Linux you get:   
>>> locale.getdefaultlocale()   
Traceback (most recent call last):   
  File "<stdin>", line 1, in ?   
  File "/usr/lib/python2.2/", line 337, in   
    return _parse_localename(localename)   
  File "/usr/lib/python2.2/", line 271, in   
    raise ValueError, 'unknown locale: %s' %   
ValueError: unknown locale: de_DE@euro   
Evidently, Python2.2's locale module is unaware of 
the "somelang_SOMELANG@euro" nomenclature  
for euro-enabled locales on Linux.  
msg10716 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-06-09 09:10
Logged In: YES 

Can you please explain what you need getdefaultlocale for?
msg10717 - (view) Author: Chema Cortés (chemacortes) Date: 2002-07-06 01:11
Logged In: YES 

We, as non-english writers, need 'getdefaultlocale' to set the default encoding for 
unicode strings: 
The problem can be fixed easyly by insert the new locales into the locale_alias of 
module locale: 
  "de_de@euro": "de_DE.iso8859_15", 
  "de_at@euro": "de_AT@iso8859_15", 
As a workarround, you can modify the locale_alias into the 
# adding euro locales 
import locale 
eurolocs=[ "ca_ES", "da_DK", "de_AT", "de_BE", "de_DE", "de_LU", "en_BE", 
           "en_IE", "es_ES", "eu_ES", "fi_FI", "fr_BE", "fr_FR", "fr_LU", 
           "ga_IE", "gl_ES", "it_IT", "nl_BE", "nl_NL", "pt_PT", "sv_FI" 
for l in eurolocs: 
   key=l.lower()+"@euro"          # eg: "es_es@euro" 
   cod=l+".iso8859_15"            # eg: "es_ES.iso8859_15" 
# Setting the unicode default encoding 
import sys 
if hasattr(sys,"setdefaultencoding"): 
msg10718 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-07-08 08:55
Logged In: YES 

I see. For that, you should not use getdefaultlocale. The
reason is that getdefaultlocale cannot possibly determine
the locale's encoding correctly. Instead, you should use
locale.nl_langinfo where available (invoking setlocale

The fix you are reporting as 'easy' is a hack rather than a
solution: there is no guarantee whatsoever that the encoding
in a @euro locale will be Latin-9; it could just as well be,
say, UTF-8. Likewise, there might be other locales with
implied encodings.
msg10719 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-11-03 03:29
Logged In: YES 

Martin, should this be closed?  Is there a bug?
msg10720 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-11-03 08:02
Logged In: YES 

There is a shallow bug, namely that


crashes; it should return the same value that it does for
de_DE, or perhaps it should have hard-coded knowledge that
the codeset is iso-8859-15.

There is a deeper underlying bug that getdefaultlocale is a
hopeless case. I'll be adding a locale.getpreferredencoding
function to make getdefaultlocale unnecessary.
msg10721 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-11-03 17:24
Logged In: YES 

This is now fixed in 1.22 and; 1.5;
NEWS 1.506;
liblocale.tex 1.31;

The @euro modifier will now imply Latin-9; as indicated,
this might be bogus, but is better than the current behaviour.
msg10722 - (view) Author: Florian Konnertz (groovehunter) Date: 2003-02-19 10:49
Logged In: YES 

I'm newbie to the Python bug tracker so maybe i missed
something, but...

...isn't this issue still open for 2.1.3. 

for my error report.
msg10723 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-03-02 11:45
Logged In: YES 

Python 2.1.3, in itself, cannot be changed anymore - it has
already been released, and for some reason, the time machine
won't allow to modify a release...

Python 2.1 is essentially not maintained anymore. Anything
that is fixed in CVS is marked as fixed in the tracker; if
there is interest, backports to 2.2 are still accepted.

Either upgrade to 2.2, or accept the bug, or backport the
necessary changes.
Date User Action Args
2002-05-10 21:02:32vinwehcreate