Skip to content

Commit

Permalink
Simplify TextIOWrapper usage
Browse files Browse the repository at this point in the history
  • Loading branch information
dhimmel committed Dec 13, 2016
1 parent 4774b75 commit 640dc1b
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,6 @@ def _get_handle(path_or_buf, mode, encoding=None, compression=None,

handles.append(f)

# In Python 3
if compat.PY3:
from io import TextIOWrapper
f = TextIOWrapper(f, encoding=encoding)
handles.append(f)

return f, handles

elif is_path:
if compat.PY2:
# Python 2
Expand All @@ -380,7 +372,7 @@ def _get_handle(path_or_buf, mode, encoding=None, compression=None,
handles.append(f)

# in Python 3, convert BytesIO or fileobjects passed with an encoding
if compat.PY3 and isinstance(path_or_buf, compat.BytesIO):
if compat.PY3 and (compression or isinstance(f, compat.BytesIO)):
from io import TextIOWrapper
f = TextIOWrapper(f, encoding=encoding)
handles.append(f)
Expand Down

0 comments on commit 640dc1b

Please sign in to comment.