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: lt_LT (patch)
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: anthonybaxter, nerijus, sorlov
Priority: normal Keywords: patch

Created on 2005-02-08 02:39 by nerijus, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
locale.py.diff nerijus, 2005-02-08 02:39 patch for Lib/locale.py
Messages (9)
msg47722 - (view) Author: Nerijus Baliunas (nerijus) Date: 2005-02-08 02:39
When running wxPython app I get:
...
    from wx._core import *
  File
"/usr/lib/python2.3/site-packages/wx-2.5.4-gtk2-ansi/wx/_core.py",
line 11035, in ?
    default = locale.getdefaultlocale()[1]
  File "/usr/lib/python2.3/locale.py", line 346, in
getdefaultlocale
    return _parse_localename(localename)
  File "/usr/lib/python2.3/locale.py", line 280, in
_parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: lt_LT

Attached patch helps.
I also changed Latvian, as ISO8859-13 is an official
standard in both Latvia and Lithuania, and Estonian, as
they use ISO8859-15 now. Also added Windows language
identifiers for all 3 languages.

It can be applied to both 2.3 and 2.4.
msg47723 - (view) Author: Nerijus Baliunas (nerijus) Date: 2005-02-27 22:14
Logged In: YES 
user_id=3416

I'm increasing priority, as I have real world application
(OpenDict using wxPython) not starting w/o this patch:
$ opendict 
...
ValueError: unknown locale: lt_LT

It's really a very simple patch, please apply it to both 2.3
and 2.4.
msg47724 - (view) Author: Serge Orlov (sorlov) Date: 2005-03-09 18:31
Logged In: YES 
user_id=1235914

I don't think the values in locale_alias should be changed
in minor releases (They have been changed in 2.5 as in your
patch)  Please apply changes that only add lt_lt and lv_lv
aliases. I suspect the whole alias thing has wrong values
for many countries (not only in Python). At least it has
wrong values for Russian in Solaris and Linux for more than
ten years. I know that many Russian users have given up
relying on it. They just set charset explicitly: 
LANG=ru_RU.koi8-r or LANG=ru_RU.utf-8. Nerijus,
LANG=lt_LT.ISO8859-13 should work for you. Besides OpenDict
should catch the exception, print a warning and fall back to
C locale if the locale set by the user is not available.

The windows language identifiers are OK to add.
msg47725 - (view) Author: Nerijus Baliunas (nerijus) Date: 2005-03-09 23:47
Logged In: YES 
user_id=3416

$ set|grep LANG
LANG=lt_LT.ISO8859-13
My LANG is already as you suggest.

OK, I'll ask wxPython developer, as with earlier wxPython
versions I didn't have such problem. But my patch should be
safe anyway.
msg47726 - (view) Author: Serge Orlov (sorlov) Date: 2005-03-10 13:33
Logged In: YES 
user_id=1235914

That's strange, it works for me, as you see there is no
exception for lt_LT.iso8859-13. I've been using this "fix"
in Linux and Solaris for many years. I'm for applying this
patch to 2.3 and 2.4 but without changing charset as it's
unknown if there are users that depend on the current value. 

Python 2.3.3 (#1, Jun 30 2004, 21:13:17)
[GCC 3.3.3 (SuSE Linux)] on linux2

>>> os.environ['LANG']='lt_LT'
>>> locale.getdefaultlocale()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib64/python2.3/locale.py", line 346, in
getdefaultlocale
    return _parse_localename(localename)
  File "/usr/lib64/python2.3/locale.py", line 280, in
_parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: lt_LT
>>> os.environ['LANG']='lt_LT.iso8859-13'
>>> locale.getdefaultlocale()
['lt_LT', 'iso8859-13']
msg47727 - (view) Author: Serge Orlov (sorlov) Date: 2005-03-10 18:52
Logged In: YES 
user_id=1235914

That's strange, it works for me, as you see there is no
exception for lt_LT.iso8859-13. I've been using this "fix"
in Linux and Solaris for many years. I'm for applying this
patch to 2.3 and 2.4 but without changing charset as it's
unknown if there are users that depend on the current value. 

Python 2.3.3 (#1, Jun 30 2004, 21:13:17)
[GCC 3.3.3 (SuSE Linux)] on linux2

>>> os.environ['LANG']='lt_LT'
>>> locale.getdefaultlocale()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib64/python2.3/locale.py", line 346, in
getdefaultlocale
    return _parse_localename(localename)
  File "/usr/lib64/python2.3/locale.py", line 280, in
_parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: lt_LT
>>> os.environ['LANG']='lt_LT.iso8859-13'
>>> locale.getdefaultlocale()
['lt_LT', 'iso8859-13']
msg47728 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2005-03-16 04:16
Logged In: YES 
user_id=29957

Please don't mess with the priority settings in the tracker.
msg47729 - (view) Author: Nerijus Baliunas (nerijus) Date: 2005-03-18 00:52
Logged In: YES 
user_id=3416

I found something. locale.getdefaultlocale()[1] fails if I have:
$ set|grep lt_LT
LANG=lt_LT.ISO8859-13
LC_ALL=lt_LT
LC_CTYPE=lt_LT

But, if I explicitly set LC_ALL=lt_LT.ISO8859-13, it works.
I didn't change my locale settings for years. So something
changed in either wxPython or python.
msg47730 - (view) Author: Nerijus Baliunas (nerijus) Date: 2006-03-02 00:27
Logged In: YES 
user_id=3416

OK, it is fixed (workarounded) in wxPython now, but I still
get the same problem (ValueError: unknown locale: lt_LT)
with PyGtk application. But as it won't be fixed in python
2.4 and it is fixed in python 2.5 (svn), I'm closing this issue.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41545
2005-02-08 02:39:31nerijuscreate