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: locale.getpreferredencoding fails on AIX
Type: Stage:
Components: Extension Modules Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: loewis Nosy List: loewis, nnorwitz
Priority: normal Keywords:

Created on 2003-01-31 18:01 by nnorwitz, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (6)
msg14336 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-01-31 18:01
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.
msg14337 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-03-03 23:11
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.
msg14338 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-03-21 03:28
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?
msg14339 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-03-21 07:10
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.
msg14340 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-03-21 15:36
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'.
msg14341 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-03-30 15:57
Logged In: YES 
user_id=21627

I guess the empty string should be accepted (although this
is debatable: it won't honor the user preferences if the
user had some).

Fixed in locale.py 1.25.
History
Date User Action Args
2022-04-10 16:06:23adminsetgithub: 37882
2003-01-31 18:01:33nnorwitzcreate