[Python-bugs-list] [ python-Bugs-797447 ] locale.setlocale(locale.LC_ALL, "de") raises exception

SourceForge.net noreply at sourceforge.net
Fri Aug 29 12:16:07 EDT 2003


Bugs item #797447, was opened at 2003-08-29 18:16
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=797447&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Peter Otten (potten)
Assigned to: Nobody/Anonymous (nobody)
Summary: locale.setlocale(locale.LC_ALL, "de") raises exception

Initial Comment:
Python 2.3 (#1, Jul 30 2003, 11:19:43) 
[GCC 3.2] on linux2 
Type "help", "copyright", "credits" or "license" for more 
information. 
>>> import locale as lo 
>>> lo.setlocale(lo.LC_ALL, 'de') 
Traceback (most recent call last): 
  File "<stdin>", line 1, in ? 
  File "/usr/local/lib/python2.3/locale.py", line 381, in 
setlocale 
    return _setlocale(category, locale) 
locale.Error: locale setting not supported 
 
The above was taken from the example section of the 
locale module documentation. 
 
But this works: 
 
>>> lo.setlocale(lo.LC_ALL, 'de_DE') 
'de_DE' 
>>> 
 
So the error message should at least be changed to 
"unknown/unsupported locale" and the documentation 
example updated to 'de_DE' instead of 'de'. 
 
However, if there are no side effects, I'd prefer to 
change the locale.setlocale() implementation to always 
normalize() the locale: 
 
def setlocale(category, locale=None): 
    if locale: 
        if type(locale) is not type(""): 
            # convert to string 
            locale = _build_localename(locale) 
        locale = normalize(locale) 
    return _setlocale(category, locale) 
 

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

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



More information about the Python-bugs-list mailing list