diff --git a/pandas/core/common.py b/pandas/core/common.py index b16c4d445a256..7b7271a52202a 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -1096,8 +1096,6 @@ def _get_handle(path, mode, encoding=None): f = open(path, mode, errors='replace') else: f = open(path, mode) - if encoding is not None and 'r' in mode: - f = UTF8Recoder(f, encoding) return f if py3compat.PY3: # pragma: no cover @@ -1118,7 +1116,7 @@ class UnicodeReader: """ def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds): - # f = UTF8Recoder(f, encoding) + f = UTF8Recoder(f, encoding) self.reader = csv.reader(f, dialect=dialect, **kwds) def next(self): diff --git a/pandas/io/tests/test_parsers.py b/pandas/io/tests/test_parsers.py index f48b561ff56e8..c045da001d683 100644 --- a/pandas/io/tests/test_parsers.py +++ b/pandas/io/tests/test_parsers.py @@ -1640,6 +1640,10 @@ def test_utf16_example(self): result = self.read_table(path, encoding='utf-16') self.assertEquals(len(result), 50) + buf = BytesIO(open(path, 'rb').read()) + result = self.read_table(buf, encoding='utf-16') + self.assertEquals(len(result), 50) + class TestCParserHighMemory(ParserTests, unittest.TestCase): def read_csv(self, *args, **kwds):