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

Include __enter__ in shim

parent 7794b1b0
......@@ -17,10 +17,11 @@ except AttributeError:
def _tarfile_open_ex(*args, **kwargs):
"""
Extend result with an __exit__ to close the file.
Extend result as a context manager.
"""
res = tarfile.open(*args, **kwargs)
res.__exit__ = lambda self: self.close()
res.__enter__ = lambda self: self
return res
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