Skip to content

Commit a5c54ad

Browse files
committed
Merge pull request #9845 from dstephens99/locale_util
BUG: raw_locales unreachable in util.testing.get_locales
2 parents 3a44ba4 + 2a6282d commit a5c54ad

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

pandas/tests/test_util.py

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def test_warning(self):
7979
with tm.assert_produces_warning(FutureWarning):
8080
self.assertNotAlmostEquals(1, 2)
8181

82+
def test_locale(self):
83+
#GH9744
84+
locales = pandas.util.testing.get_locales()
85+
self.assertTrue(len(locales) >= 1)
8286

8387
def test_rands():
8488
r = tm.rands(10)

pandas/util/testing.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -331,19 +331,21 @@ def get_locales(prefix=None, normalize=True,
331331
# raw_locales is "\n" seperated list of locales
332332
# it may contain non-decodable parts, so split
333333
# extract what we can and then rejoin.
334-
raw_locales = []
334+
raw_locales = raw_locales.split(b'\n')
335+
out_locales = []
335336
for x in raw_locales:
336-
try:
337-
raw_locales.append(str(x, encoding=pd.options.display.encoding))
338-
except:
339-
pass
337+
if compat.PY3:
338+
out_locales.append(str(x, encoding=pd.options.display.encoding))
339+
else:
340+
out_locales.append(str(x))
341+
340342
except TypeError:
341343
pass
342344

343345
if prefix is None:
344-
return _valid_locales(raw_locales, normalize)
346+
return _valid_locales(out_locales, normalize)
345347

346-
found = re.compile('%s.*' % prefix).findall('\n'.join(raw_locales))
348+
found = re.compile('%s.*' % prefix).findall('\n'.join(out_locales))
347349
return _valid_locales(found, normalize)
348350

349351

0 commit comments

Comments
 (0)