summaryrefslogtreecommitdiffstats
path: root/Lib/test/test__locale.py
diff options
context:
space:
mode:
authorJohannes Gijsbers <jlg@dds.nl>2004-08-14 10:56:54 (GMT)
committerJohannes Gijsbers <jlg@dds.nl>2004-08-14 10:56:54 (GMT)
commit404b06814c1e6d527b6e659a907ca1b15a6eaa28 (patch)
treef3c1fc8dcf5d0b9df5469d2d6e9e862b25a4d32a /Lib/test/test__locale.py
parent7c399d3e68545f4d86de31d699e82d9919a2d8f5 (diff)
downloadcpython-404b06814c1e6d527b6e659a907ca1b15a6eaa28.zip
cpython-404b06814c1e6d527b6e659a907ca1b15a6eaa28.tar.gz
cpython-404b06814c1e6d527b6e659a907ca1b15a6eaa28.tar.bz2
Reset old locale after running tests. Not doing so broke
test_format/test_unicode in some circumstances (patch #1007539/bug #992078).
Diffstat (limited to 'Lib/test/test__locale.py')
-rw-r--r--Lib/test/test__locale.py42
1 files changed, 23 insertions, 19 deletions
diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py
index be1d2ba..c113c63 100644
--- a/Lib/test/test__locale.py
+++ b/Lib/test/test__locale.py
@@ -13,22 +13,26 @@ candidate_locales = ['es_UY', 'fr_FR', 'fi_FI', 'es_CO', 'pt_PT', 'it_IT',
'eu_ES', 'vi_VN', 'af_ZA', 'nb_NO', 'en_DK', 'tg_TJ',
'es_ES.ISO8859-1', 'fr_FR.ISO8859-15', 'ru_RU.KOI8-R', 'ko_KR.eucKR']
-saw_locale = 0
-for loc in candidate_locales:
- try:
- setlocale(LC_NUMERIC, loc)
- except Error:
- continue
- if verbose:
- print "locale %r" % loc
- saw_locale = 1
- nl_radixchar = nl_langinfo(RADIXCHAR)
- li_radixchar = localeconv()['decimal_point']
- if nl_radixchar != li_radixchar:
- print "%r != %r" % (nl_radixchar, li_radixchar)
- nl_radixchar = nl_langinfo(THOUSEP)
- li_radixchar = localeconv()['thousands_sep']
- if nl_radixchar != li_radixchar:
- print "%r != %r" % (nl_radixchar, li_radixchar)
-if not saw_locale:
- raise ImportError, "None of the listed locales found"
+oldlocale = setlocale(LC_NUMERIC)
+try:
+ saw_locale = 0
+ for loc in candidate_locales:
+ try:
+ setlocale(LC_NUMERIC, loc)
+ except Error:
+ continue
+ if verbose:
+ print "locale %r" % loc
+ saw_locale = 1
+ nl_radixchar = nl_langinfo(RADIXCHAR)
+ li_radixchar = localeconv()['decimal_point']
+ if nl_radixchar != li_radixchar:
+ print "%r != %r" % (nl_radixchar, li_radixchar)
+ nl_radixchar = nl_langinfo(THOUSEP)
+ li_radixchar = localeconv()['thousands_sep']
+ if nl_radixchar != li_radixchar:
+ print "%r != %r" % (nl_radixchar, li_radixchar)
+ if not saw_locale:
+ raise ImportError, "None of the listed locales found"
+finally:
+ setlocale(LC_NUMERIC, oldlocale)