Commits

Vinay Sajip  committed 6af0aa7

Added a tempdir context manager.

  • Participants
  • Parent commits 5492e84

Comments (0)

Files changed (1)

File distlib/util.py

 import ssl
 import sys
 import tarfile
+import tempfile
 import time
 import zipfile
 
     return c
 
 @contextlib.contextmanager
+def tempdir():
+    td = tempfile.mkdtemp()
+    try:
+        yield td
+    finally:
+        shutil.rmtree(td)
+
+@contextlib.contextmanager
 def chdir(d):
     cwd = os.getcwd()
     try: