diff --git a/pandas/tests/test_util.py b/pandas/tests/test_util.py index 2e22b33dc769a..bb8bd3df96b71 100644 --- a/pandas/tests/test_util.py +++ b/pandas/tests/test_util.py @@ -79,6 +79,10 @@ def test_warning(self): with tm.assert_produces_warning(FutureWarning): self.assertNotAlmostEquals(1, 2) + def test_locale(self): + #GH9744 + locales = pandas.util.testing.get_locales() + self.assertTrue(len(locales) >= 1) def test_rands(): r = tm.rands(10) diff --git a/pandas/util/testing.py b/pandas/util/testing.py index 3d9a0e7b43634..b4baedada46e1 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -331,19 +331,21 @@ def get_locales(prefix=None, normalize=True, # raw_locales is "\n" seperated list of locales # it may contain non-decodable parts, so split # extract what we can and then rejoin. - raw_locales = [] + raw_locales = raw_locales.split(b'\n') + out_locales = [] for x in raw_locales: - try: - raw_locales.append(str(x, encoding=pd.options.display.encoding)) - except: - pass + if compat.PY3: + out_locales.append(str(x, encoding=pd.options.display.encoding)) + else: + out_locales.append(str(x)) + except TypeError: pass if prefix is None: - return _valid_locales(raw_locales, normalize) + return _valid_locales(out_locales, normalize) - found = re.compile('%s.*' % prefix).findall('\n'.join(raw_locales)) + found = re.compile('%s.*' % prefix).findall('\n'.join(out_locales)) return _valid_locales(found, normalize)