[ python-Bugs-1223976 ] error locale.getlocale() with LANGUAGE=eu_ES

SourceForge.net noreply at sourceforge.net
Mon Nov 14 00:23:58 CET 2005


Bugs item #1223976, was opened at 2005-06-20 10:40
Message generated for change (Comment added) made by lemburg
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1223976&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Zunbeltz Izaola (zunbeltz)
Assigned to: Nobody/Anonymous (nobody)
Summary: error locale.getlocale() with LANGUAGE=eu_ES

Initial Comment:
I had sumited this bug (id 1177674) and it has been
closed becouse my bad explanation. 

My locale is set to LANGUAGE=eu_ES

This is what i get in the interpreter

Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.

>>> import locale
>>> locale.getlocale()
(None, None)
>>> locale.setlocale(locale.LC_ALL, '')
'eu_ES'
>>>
>>> locale.getlocale()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/locale.py", line 365, in
getlocale
    return _parse_localename(localename)
  File "/usr/lib/python2.4/locale.py", line 278, in
_parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: eu_ES
>>>


----------------------------------------------------------------------

>Comment By: M.-A. Lemburg (lemburg)
Date: 2005-11-14 00:23

Message:
Logged In: YES 
user_id=38388

Not so fast, Martin. I know that you don't like the
function, but there's no reason to remove it.

Note that this bug is fixed in CVS: 

I updated the locale database with the most recent X.org
data last December. It does include the eu_es mapping, but
doesn't have the basque mapping.


----------------------------------------------------------------------

Comment By: Nikos Kouremenos (nkour)
Date: 2005-11-13 23:43

Message:
Logged In: YES 
user_id=865368

python itself uses this func,

I don't even ask getlocale()!

I just do:

time.strptime(tim, '%Y%m%dT%H:%M:%S')

somewhere and enjoy:

time.strptime(tim, '%Y%m%dT%H:%M:%S')
  File "/usr/lib/python2.4/_strptime.py", line 269, in ?
    _TimeRE_cache = TimeRE()
  File "/usr/lib/python2.4/_strptime.py", line 188, in __init__
    self.locale_time = LocaleTime()
  File "/usr/lib/python2.4/_strptime.py", line 73, in __init__
    self.lang = _getlang()
  File "/usr/lib/python2.4/_strptime.py", line 32, in _getlang
    return locale.getlocale(locale.LC_TIME)
  File "/usr/lib/python2.4/locale.py", line 363, in getlocale
    return _parse_localename(localename)
  File "/usr/lib/python2.4/locale.py", line 278, in
_parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: eu_ES

so basque feels like he's ATIA here

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2005-11-13 23:36

Message:
Logged In: YES 
user_id=21627

It was a candid question: why do you need getlocale()? This
function is inherently broken, not just for basque, and
there is no way to fix it for good. So it would be best to
remove the function entirely.

Before such a step can be taken, I need to know why people
use it in the first place.

----------------------------------------------------------------------

Comment By: Nikos Kouremenos (nkour)
Date: 2005-11-13 22:30

Message:
Logged In: YES 
user_id=865368

this bug is REAL and major IMO

any app that uses localization cannot be runned by a basque

python is not aware of eu_ES at all!

I don't know if this solves it (I'm not basque)

--- /usr/lib/python2.4/locale.py        2005-11-12
11:59:16.000000000 +0200
+++ /tmp/locale.py      2005-11-13 23:27:27.000000000 +0200
@@ -481,6 +481,7 @@
         'ar_aa':                         'ar_AA.ISO8859-6',
         'ar_sa':                         'ar_SA.ISO8859-6',
         'arabic':                        'ar_AA.ISO8859-6',
+        'basque':                        'eu_ES.ISO8859-1',
         'bg':                            'bg_BG.ISO8859-5',
         'bg_bg':                         'bg_BG.ISO8859-5',
         'bulgarian':                     'bg_BG.ISO8859-5',
@@ -540,6 +541,7 @@
         'es_ve':                         'es_VE.ISO8859-1',
         'et':                            'et_EE.ISO8859-4',
         'et_ee':                         'et_EE.ISO8859-4',
+        'eu_ES':                         'eu_ES.ISO8859-1',
         'fi':                            'fi_FI.ISO8859-1',
         'fi_fi':                         'fi_FI.ISO8859-1',
         'finnish':                       'fi_FI.ISO8859-1',


btw for this not to happen again (sad to see py242 not
fixing this) http://www.mpi-sb.mpg.de/~pesca/locales.html

Zunbeltz Izaola is a courageous man, and please loweis think
a bit more before replying why do you need that and this

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2005-07-06 07:28

Message:
Logged In: YES 
user_id=21627

What do you need locale.getlocale() for? If it is to
determine the encoding, I recommend to use
locale.getpreferredencoding() instead.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1223976&group_id=5470


More information about the Python-bugs-list mailing list