Commit eb61e5c9 authored by Jason R. Coombs's avatar Jason R. Coombs

Use contextlib.closing on tarfile compat shim

parent ec6e6fb1
import sys
import unittest
import tarfile
import contextlib
try:
# provide skipIf for Python 2.4-2.6
......@@ -19,9 +20,6 @@ def _tarfile_open_ex(*args, **kwargs):
"""
Extend result as a context manager.
"""
res = tarfile.open(*args, **kwargs)
res.__exit__ = lambda exc_type, exc_value, traceback: res.close()
res.__enter__ = lambda: res
return res
return contextlib.closing(tarfile.open(*args, **kwargs))
tarfile_open = _tarfile_open_ex if sys.version_info < (2,7) else tarfile.open
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment