Remove ZipFile support for Python 2.6 · pandas-dev/pandas@f0901fb (original) (raw)
`@@ -5,7 +5,6 @@
`
5
5
`import csv
`
6
6
`import codecs
`
7
7
`import mmap
`
8
``
`-
import zipfile
`
9
8
`from contextlib import contextmanager, closing
`
10
9
``
11
10
`from pandas.compat import StringIO, BytesIO, string_types, text_type
`
`@@ -276,17 +275,6 @@ def file_path_to_url(path):
`
276
275
`return urljoin('file:', pathname2url(path))
`
277
276
``
278
277
``
279
``
`-
ZipFile is not a context manager for <= 2.6
`
280
``
`-
must be tuple index here since 2.6 doesn't use namedtuple for version_info
`
281
``
`-
if compat.PY2 and sys.version_info[1] <= 6:
`
282
``
`-
@contextmanager
`
283
``
`-
def ZipFile(*args, **kwargs):
`
284
``
`-
with closing(zipfile.ZipFile(*args, **kwargs)) as zf:
`
285
``
`-
yield zf
`
286
``
`-
else:
`
287
``
`-
ZipFile = zipfile.ZipFile
`
288
``
-
289
``
-
290
278
`def _get_handle(source, mode, encoding=None, compression=None,
`
291
279
`memory_map=False):
`
292
280
`"""
`
`@@ -330,6 +318,7 @@ def _get_handle(source, mode, encoding=None, compression=None,
`
330
318
``
331
319
`# ZIP Compression
`
332
320
`elif compression == 'zip':
`
``
321
`+
import zipfile
`
333
322
`zip_file = zipfile.ZipFile(source)
`
334
323
`try:
`
335
324
`name, = zip_file.namelist()
`