[Python-bugs-list] [ python-Bugs-678259 ] locale.getpreferredencoding fails on AIX

SourceForge.net noreply@sourceforge.net
Fri, 21 Mar 2003 07:36:59 -0800


Bugs item #678259, was opened at 2003-01-31 13:01
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=678259&group_id=5470

Category: Extension Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Neal Norwitz (nnorwitz)
Assigned to: Martin v. Löwis (loewis)
Summary: locale.getpreferredencoding fails on AIX

Initial Comment:

The problem is setting LC_CTYPE to an empty string:

>>> locale.setlocale(locale.LC_CTYPE, '')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/neal/python/dist/aix/Lib/locale.py", line 
381, in setlocale
    return _setlocale(category, locale)
locale.Error: locale setting not supported

Putting a try/except around the setlocale call in 
getpreferredencoding allows the test to pass.  I don't 
know if this is correct.

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

>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-03-21 10:36

Message:
Logged In: YES 
user_id=33168

The traceback from the original report was not the same as
my last comment.  The original problem seems to be gone.  I
don't know what changed, but the localemodule builds and
tests correctly.  However, before getting the module to
build, I was using the python version.  The python version
of setlocale() doesn't support setting a value to an empty
string.  Based on your first comment, it seems the python
version (line 72 of locale.py) should allow the value to be
either '' or 'C'.

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

Comment By: Martin v. Löwis (loewis)
Date: 2003-03-21 02:10

Message:
Logged In: YES 
user_id=21627

I don't understand. In the traceback, it says that
_setlocale is invoked, which is the function from
_localemodule. Since the locale argument is still an empty
string, it still seems to be a flaw in the AIX
implementation, or else the user has environment settings
which are not supported by AIX.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-03-20 22:28

Message:
Logged In: YES 
user_id=33168

The problem was that the setlocale in Lib/locale.py was
being used, not from Modules/_localemodule.c.  In the python
version, it does not allow an empty string.  Seems like this
should be changed, do you agree?

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

Comment By: Martin v. Löwis (loewis)
Date: 2003-03-03 18:11

Message:
Logged In: YES 
user_id=21627

What are the relevant environment settings? According to

http://nscp.upenn.edu/aix4.3html/libs/basetrf2/setlocale.htm

specifying "" as the second argument of setlocale is
supported, and means the same thing as it does on all other
systems: take locale settings from the user preferences.

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

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