@@ -1791,10 +1791,18 @@ def __init__(self, f, **kwds): |
|
|
1791 |
1791 |
self.comment = kwds['comment'] |
1792 |
1792 |
self._comment_lines = [] |
1793 |
1793 |
|
|
1794 |
+add_handle = ( |
|
1795 |
+isinstance(f, compat.string_types) or |
|
1796 |
+self.compression or |
|
1797 |
+ (compat.PY3 and isinstance(f, compat.BytesIO)) |
|
1798 |
+ ) |
|
1799 |
+ |
1794 |
1800 |
f = _get_handle(f, 'r', encoding=self.encoding, |
1795 |
1801 |
compression=self.compression, |
1796 |
1802 |
memory_map=self.memory_map) |
1797 |
|
-self.handles.append(f) |
|
1803 |
+ |
|
1804 |
+if add_handle: |
|
1805 |
+self.handles.append(f) |
1798 |
1806 |
|
1799 |
1807 |
# Set self.data to something that can read lines. |
1800 |
1808 |
if hasattr(f, 'readline'): |