This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: unknown locale de_DE@euro on Suse 8.0 Linux
Type: Stage:
Components: Library (Lib) Versions: Python 2.2
process
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 2022-04-10 16:05 by admin. 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/locale.py", line 337, in   
getdefaultlocale   
    return _parse_localename(localename)   
  File "/usr/lib/python2.2/locale.py", line 271, in   
_parse_localename   
    raise ValueError, 'unknown locale: %s' %   
localename   
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 
user_id=21627

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 
user_id=78289

We, as non-english writers, need 'getdefaultlocale' to set the default encoding for 
unicode strings: 
 
lang,encoding=locale.getdefaultlocale() 
sys.setdefaultencoding(encoding) 
 
The problem can be fixed easyly by insert the new locales into the locale_alias of 
module locale: 
 
locale_alias={ 
... 
  "de_de@euro": "de_DE.iso8859_15", 
  "de_at@euro": "de_AT@iso8859_15", 
  "es_es@euro":"es_ES@iso8859_15", 
... 
} 
 
As a workarround, you can modify the locale_alias into the sitecustomize.py 
 
# 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" 
   locale.locale_alias[key]=cod 
 
# Setting the unicode default encoding 
import sys 
if hasattr(sys,"setdefaultencoding"): 
  lang,encoding=locale.getdefaultlocale() 
  sys.setdefaultencoding(encoding) 
 
msg10718 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-07-08 08:55
Logged In: YES 
user_id=21627

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
beforehand).

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 
user_id=33168

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 
user_id=21627

There is a shallow bug, namely that

locale._parse_localename("de_DE@euro")

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 
user_id=21627

This is now fixed in

locale.py 1.22 and 1.19.16.1;
test_locale.py 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 
user_id=548376

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

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

See  http://openspirit.homelinux.net/noowiki/python/Locale
for my error report.
msg10723 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-03-02 11:45
Logged In: YES 
user_id=21627

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.
History
Date User Action Args
2022-04-10 16:05:18adminsetgithub: 36584
2002-05-10 21:02:32vinwehcreate