Skip to content

Commit

Permalink
Do not acquire list as file handler to close
Browse files Browse the repository at this point in the history
  • Loading branch information
agraboso committed Aug 10, 2016
1 parent 7aa5184 commit 6592c73
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1766,16 +1766,18 @@ def __init__(self, f, **kwds):
f = _get_handle(f, 'r', encoding=self.encoding,
compression=self.compression,
memory_map=self.memory_map)
self.handles.append(f)
elif self.compression:
f = _wrap_compressed(f, self.compression, self.encoding)
self.handles.append(f)
# in Python 3, convert BytesIO or fileobjects passed with an encoding
elif compat.PY3 and isinstance(f, compat.BytesIO):
from io import TextIOWrapper

f = TextIOWrapper(f, encoding=self.encoding)
self.handles.append(f)

# Set self.data to something that can read lines.
self.handles.append(f)
if hasattr(f, 'readline'):
self._make_reader(f)
else:
Expand Down

0 comments on commit 6592c73

Please sign in to comment.