[Python-checkins] cpython: Closes #12391: temporary files are now cleaned up.

vinay.sajip python-checkins at python.org
Thu Jul 7 13:59:39 CEST 2011


http://hg.python.org/cpython/rev/a4405b799e1b
changeset:   71245:a4405b799e1b
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Thu Jul 07 12:59:31 2011 +0100
summary:
  Closes #12391: temporary files are now cleaned up.

files:
  Lib/packaging/install.py |  12 +++++-------
  1 files changed, 5 insertions(+), 7 deletions(-)


diff --git a/Lib/packaging/install.py b/Lib/packaging/install.py
--- a/Lib/packaging/install.py
+++ b/Lib/packaging/install.py
@@ -42,10 +42,7 @@
 
     :param files: a list of files to move.
     :param destination: the destination directory to put on the files.
-                        if not defined, create a new one, using mkdtemp
     """
-    if not destination:
-        destination = tempfile.mkdtemp()
 
     for old in files:
         filename = os.path.split(old)[-1]
@@ -126,8 +123,11 @@
     elif _is_archive_file(path):
         logger.info('Installing from archive: %s', path)
         _unpacked_dir = tempfile.mkdtemp()
-        shutil.unpack_archive(path, _unpacked_dir)
-        return _run_install_from_archive(_unpacked_dir)
+        try:
+            shutil.unpack_archive(path, _unpacked_dir)
+            return _run_install_from_archive(_unpacked_dir)
+        finally:
+            shutil.rmtree(_unpacked_dir)
     else:
         logger.warning('No projects to install.')
         return False
@@ -179,8 +179,6 @@
     :param path: base path to install distribution in
     :param paths: list of paths (defaults to sys.path) to look for info
     """
-    if not path:
-        path = tempfile.mkdtemp()
 
     installed_dists = []
     for dist in dists:

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list