Skip to content

Commit 2f43c39

Browse files
committed
Replicate original handles appending
1 parent bc54e46 commit 2f43c39

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
@@ -1791,10 +1791,18 @@ def __init__(self, f, **kwds):
17911791
self.comment = kwds['comment']
17921792
self._comment_lines = []
17931793

1794+
add_handle = (
1795+
isinstance(f, compat.string_types) or
1796+
self.compression or
1797+
(compat.PY3 and isinstance(f, compat.BytesIO))
1798+
)
1799+
17941800
f = _get_handle(f, 'r', encoding=self.encoding,
17951801
compression=self.compression,
17961802
memory_map=self.memory_map)
1797-
self.handles.append(f)
1803+
1804+
if add_handle:
1805+
self.handles.append(f)
17981806

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

0 commit comments

Comments
 (0)