diff options
author | Anthony Baxter <anthonybaxter@gmail.com> | 2005-06-03 15:04:15 (GMT) |
---|---|---|
committer | Anthony Baxter <anthonybaxter@gmail.com> | 2005-06-03 15:04:15 (GMT) |
commit | 451ae18751671a8964f29df18a8b10f94ba55946 (patch) | |
tree | 5d9e79fd9778187a5484c4538a6ad4a4f08536e9 /Lib/test | |
parent | df88846ebca9186514e86bc2067242233ade4608 (diff) | |
download | cpython-451ae18751671a8964f29df18a8b10f94ba55946.zip cpython-451ae18751671a8964f29df18a8b10f94ba55946.tar.gz cpython-451ae18751671a8964f29df18a8b10f94ba55946.tar.bz2 |
[ 1197218 ] test_locale fix on modern linux
On more modern linuxes (and probably others) straight 'en_US' isn't a
valid locale. Make the code try a couple of alternates.
backport candidate
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_locale.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py index d8f7925..2a33aaf 100644 --- a/Lib/test/test_locale.py +++ b/Lib/test/test_locale.py @@ -7,16 +7,18 @@ if sys.platform == 'darwin': oldlocale = locale.setlocale(locale.LC_NUMERIC) if sys.platform.startswith("win"): - tloc = "en" -elif sys.platform.startswith("freebsd"): - tloc = "en_US.US-ASCII" + tlocs = ("en",) else: - tloc = "en_US" + tlocs = ("en_US.UTF-8", "en_US.US-ASCII", "en_US") -try: - locale.setlocale(locale.LC_NUMERIC, tloc) -except locale.Error: - raise ImportError, "test locale %s not supported" % tloc +for tloc in tlocs: + try: + locale.setlocale(locale.LC_NUMERIC, tloc) + break + except locale.Error: + continue +else: + raise ImportError, "test locale not supported (tried %s)"%(', '.join(tlocs)) def testformat(formatstr, value, grouping = 0, output=None): if verbose: |