Skip to content

Commit 02818df

Browse files
BUG: raw_locales unreachable in util.testing.get_locales
1 parent 2734fff commit 02818df

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

pandas/tests/test_util.py

+8
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ 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+
raw_locales = pandas.util.testing._default_locale_getter()
86+
warnings.warn(raw_locales, SyntaxWarning)
87+
warnings.warn(locales, SyntaxWarning)
88+
89+
self.assertTrue(len(locales) >= 1)
8290

8391
def test_rands():
8492
r = tm.rands(10)

pandas/util/testing.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -331,19 +331,20 @@ 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:
336337
try:
337-
raw_locales.append(str(x, encoding=pd.options.display.encoding))
338+
out_locales.append(str(x, encoding=pd.options.display.encoding))
338339
except:
339340
pass
340341
except TypeError:
341342
pass
342343

343344
if prefix is None:
344-
return _valid_locales(raw_locales, normalize)
345+
return _valid_locales(out_locales, normalize)
345346

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

349350

0 commit comments

Comments
 (0)