From: Anthony Baxter Date: Fri, 3 Jun 2005 16:01:29 +0000 (+0000) Subject: backport of [ 1197218 ] test_locale fix on modern linux X-Git-Tag: v2.4.2c1~205 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c5d8c7bc139f0321292d9e3551d5998306cfe09c;p=thirdparty%2FPython%2Fcpython.git backport of [ 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. --- diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py index d8f79250525e..2a33aafb8807 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: