Skip to content

Commit 3aba6cb

Browse files
committed
Replicate original handles appending
1 parent 101a344 commit 3aba6cb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pandas/io/parsers.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1890,10 +1890,18 @@ def __init__(self, f, **kwds):
18901890
self.comment = kwds['comment']
18911891
self._comment_lines = []
18921892

1893+
add_handle = (
1894+
isinstance(f, compat.string_types) or
1895+
self.compression or
1896+
(compat.PY3 and isinstance(f, compat.BytesIO))
1897+
)
1898+
18931899
f = _get_handle(f, 'r', encoding=self.encoding,
18941900
compression=self.compression,
18951901
memory_map=self.memory_map)
1896-
self.handles.append(f)
1902+
1903+
if add_handle:
1904+
self.handles.append(f)
18971905

18981906
# Set self.data to something that can read lines.
18991907
if hasattr(f, 'readline'):

0 commit comments

Comments
 (0)