MCPcopy Index your code
hub / github.com/python/cpython / setUpModule

Function setUpModule

Lib/test/test__locale.py:34–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32]
33
34def setUpModule():
35 global candidate_locales
36 # Issue #13441: Skip some locales (e.g. cs_CZ and hu_HU) on Solaris to
37 # workaround a mbstowcs() bug. For example, on Solaris, the hu_HU locale uses
38 # the locale encoding ISO-8859-2, the thousands separator is b'\xA0' and it is
39 # decoded as U+30000020 (an invalid character) by mbstowcs().
40 if sys.platform == 'sunos5':
41 old_locale = locale.setlocale(locale.LC_ALL)
42 try:
43 locales = []
44 for loc in candidate_locales:
45 try:
46 locale.setlocale(locale.LC_ALL, loc)
47 except Error:
48 continue
49 encoding = locale.getencoding()
50 try:
51 localeconv()
52 except Exception as err:
53 print("WARNING: Skip locale %s (encoding %s): [%s] %s"
54 % (loc, encoding, type(err), err))
55 else:
56 locales.append(loc)
57 candidate_locales = locales
58 finally:
59 locale.setlocale(locale.LC_ALL, old_locale)
60
61 # Workaround for MSVC6(debug) crash bug
62 if "MSC v.1200" in sys.version:
63 def accept(loc):
64 a = loc.split(".")
65 return not(len(a) == 2 and len(a[-1]) >= 9)
66 candidate_locales = [loc for loc in candidate_locales if accept(loc)]
67
68# List known locale values to test against when available.
69# Dict formatted as ``<locale> : (<decimal_point>, <thousands_sep>)``. If a

Callers

nothing calls this directly

Calls 3

localeconvFunction · 0.85
acceptFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…