mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
[ 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
This commit is contained in:
parent
df88846ebc
commit
451ae18751
1 changed files with 10 additions and 8 deletions
|
@ -7,16 +7,18 @@ if sys.platform == 'darwin':
|
||||||
oldlocale = locale.setlocale(locale.LC_NUMERIC)
|
oldlocale = locale.setlocale(locale.LC_NUMERIC)
|
||||||
|
|
||||||
if sys.platform.startswith("win"):
|
if sys.platform.startswith("win"):
|
||||||
tloc = "en"
|
tlocs = ("en",)
|
||||||
elif sys.platform.startswith("freebsd"):
|
|
||||||
tloc = "en_US.US-ASCII"
|
|
||||||
else:
|
else:
|
||||||
tloc = "en_US"
|
tlocs = ("en_US.UTF-8", "en_US.US-ASCII", "en_US")
|
||||||
|
|
||||||
try:
|
for tloc in tlocs:
|
||||||
|
try:
|
||||||
locale.setlocale(locale.LC_NUMERIC, tloc)
|
locale.setlocale(locale.LC_NUMERIC, tloc)
|
||||||
except locale.Error:
|
break
|
||||||
raise ImportError, "test locale %s not supported" % tloc
|
except locale.Error:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
raise ImportError, "test locale not supported (tried %s)"%(', '.join(tlocs))
|
||||||
|
|
||||||
def testformat(formatstr, value, grouping = 0, output=None):
|
def testformat(formatstr, value, grouping = 0, output=None):
|
||||||
if verbose:
|
if verbose:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue