@@ -1890,10 +1890,18 @@ def __init__(self, f, **kwds): |
|
|
1890 |
1890 |
self.comment = kwds['comment'] |
1891 |
1891 |
self._comment_lines = [] |
1892 |
1892 |
|
|
1893 |
+add_handle = ( |
|
1894 |
+isinstance(f, compat.string_types) or |
|
1895 |
+self.compression or |
|
1896 |
+ (compat.PY3 and isinstance(f, compat.BytesIO)) |
|
1897 |
+ ) |
|
1898 |
+ |
1893 |
1899 |
f = _get_handle(f, 'r', encoding=self.encoding, |
1894 |
1900 |
compression=self.compression, |
1895 |
1901 |
memory_map=self.memory_map) |
1896 |
|
-self.handles.append(f) |
|
1902 |
+ |
|
1903 |
+if add_handle: |
|
1904 |
+self.handles.append(f) |
1897 |
1905 |
|
1898 |
1906 |
# Set self.data to something that can read lines. |
1899 |
1907 |
if hasattr(f, 'readline'): |