aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests/py26compat.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-12-30 10:01:23 -0500
committerJason R. Coombs <jaraco@jaraco.com>2014-12-30 10:01:23 -0500
commit7794b1b0348f2cb76317b40a5ec7931527501c94 (patch)
treec99e1714ac7cefa33e9b436fcde3c6cb9730224d /setuptools/tests/py26compat.py
parent470028e10ea01e57ece6df3c953a309e0017d068 (diff)
downloadexternal_python_setuptools-7794b1b0348f2cb76317b40a5ec7931527501c94.tar.gz
external_python_setuptools-7794b1b0348f2cb76317b40a5ec7931527501c94.tar.bz2
external_python_setuptools-7794b1b0348f2cb76317b40a5ec7931527501c94.zip
Add compatibility shim for tarfile.open
Diffstat (limited to 'setuptools/tests/py26compat.py')
-rw-r--r--setuptools/tests/py26compat.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/setuptools/tests/py26compat.py b/setuptools/tests/py26compat.py
index d4fb891a..24e6dbe2 100644
--- a/setuptools/tests/py26compat.py
+++ b/setuptools/tests/py26compat.py
@@ -1,4 +1,6 @@
+import sys
import unittest
+import tarfile
try:
# provide skipIf for Python 2.4-2.6
@@ -12,3 +14,13 @@ except AttributeError:
return skip
return func
return skipper
+
+def _tarfile_open_ex(*args, **kwargs):
+ """
+ Extend result with an __exit__ to close the file.
+ """
+ res = tarfile.open(*args, **kwargs)
+ res.__exit__ = lambda self: self.close()
+ return res
+
+tarfile_open = _tarfile_open_ex if sys.version_info < (2,7) else tarfile.open