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: AIX locale parsing failure
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, David.Edelsohn, iritkatriel, lemburg, python-dev, trent, vstinner
Priority: normal Keywords:

Created on 2013-06-16 04:03 by David.Edelsohn, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg191257 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2013-06-16 04:03
All tests are failing for 3.x on AIX due to an error parsing the locale.  This is not failing on 3.3 branch.

  File "/home/shager/cpython-buildarea/3.x.edelsohn-aix-ppc64/build/Lib/test/regrtest.py", line 1292, in runtest_inner
    with saved_test_environment(test, verbose, quiet) as environment:
  File "/home/shager/cpython-buildarea/3.x.edelsohn-aix-ppc64/build/Lib/test/regrtest.py", line 1256, in __enter__
    in self.resource_info())
  File "/home/shager/cpython-buildarea/3.x.edelsohn-aix-ppc64/build/Lib/test/regrtest.py", line 1255, in <genexpr>
    self.saved_values = dict((name, get()) for name, get, restore
  File "/home/shager/cpython-buildarea/3.x.edelsohn-aix-ppc64/build/Lib/test/regrtest.py", line 1239, in get_locale
    pairings.append((lc, locale.getlocale(lc)))
  File "/home/shager/cpython-buildarea/3.x.edelsohn-aix-ppc64/build/Lib/locale.py", line 524, in getlocale
    return _parse_localename(localename)
  File "/home/shager/cpython-buildarea/3.x.edelsohn-aix-ppc64/build/Lib/locale.py", line 433, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: C en_US C C C C
msg191299 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2013-06-17 00:14
The problem is Lib/test/regrtest.py.

_lc = [getattr(locale, lc) for lc in dir(locale) if lc.startswith('LC_')]

The list of locales that start with 'LC_' includes LC_ALL.  On AIX, at least, setlocal("LC_ALL",NULL) returns a string with the locales for each locale category.  Lib/locale.py for getlocale() specifically says:
"category may be one of the LC_* value except LC_ALL."

The following patch fixes the AIX testing problem.

diff -r bdd60bedf933 Lib/test/regrtest.py
--- a/Lib/test/regrtest.py      Sun Jun 16 18:37:53 2013 -0400
+++ b/Lib/test/regrtest.py      Sun Jun 16 22:05:52 2013 -0700
@@ -1231,7 +1231,7 @@
             elif os.path.isdir(support.TESTFN):
                 shutil.rmtree(support.TESTFN)
 
-    _lc = [getattr(locale, lc) for lc in dir(locale) if lc.startswith('LC_')]
+    _lc = [getattr(locale, lc) for lc in dir(locale) if lc.startswith('LC_') and lc != 'LC_ALL']
     def get_locale(self):
         pairings = []
         for lc in self._lc:
msg191357 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-06-17 18:40
New changeset 00824f9e29f3 by Victor Stinner in branch 'default':
Issue #18228: Fix locale test of test.regrtest.saved_test_environment
http://hg.python.org/cpython/rev/00824f9e29f3
msg191368 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-06-17 19:28
New changeset 6cbd992d3411 by Victor Stinner in branch 'default':
Issue #18228: Use locale.setlocale(name, None) instead of
http://hg.python.org/cpython/rev/6cbd992d3411
msg222843 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-12 14:45
Presumably this can be closed as fixed.
msg377838 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-10-02 21:59
Looks like this can be closed.
msg377892 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-10-03 17:06
Sorry, I forgot to close it 7 years ago. Done ;-)
History
Date User Action Args
2022-04-11 14:57:46adminsetgithub: 62428
2020-10-03 17:06:27vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg377892

stage: resolved
2020-10-02 21:59:50iritkatrielsetstatus: pending -> open
nosy: + iritkatriel
messages: + msg377838

2014-10-02 09:53:02serhiy.storchakasetstatus: open -> pending
2014-07-12 14:45:33BreamoreBoysetstatus: pending -> open
nosy: + BreamoreBoy
messages: + msg222843

2014-01-29 07:11:25serhiy.storchakasetstatus: open -> pending
2013-06-18 14:11:14David.Edelsohnsetversions: - Python 2.7, Python 3.3
2013-06-18 14:10:37David.Edelsohnsetversions: + Python 2.7, Python 3.3
2013-06-17 19:28:39python-devsetmessages: + msg191368
2013-06-17 18:40:20python-devsetnosy: + python-dev
messages: + msg191357
2013-06-17 00:14:18David.Edelsohnsetmessages: + msg191299
2013-06-16 21:32:01pitrousetnosy: + lemburg, vstinner, trent
2013-06-16 04:03:15David.Edelsohncreate