[Python-checkins] r75386 - in sandbox/branches/setuptools-0.6: pkg_resources.py setuptools/archive_util.py

phillip.eby python-checkins at python.org
Mon Oct 12 22:05:56 CEST 2009


Author: phillip.eby
Date: Mon Oct 12 22:05:56 2009
New Revision: 75386

Log:
Backport fixes for issues 16 & 23 from trunk


Modified:
   sandbox/branches/setuptools-0.6/pkg_resources.py
   sandbox/branches/setuptools-0.6/setuptools/archive_util.py

Modified: sandbox/branches/setuptools-0.6/pkg_resources.py
==============================================================================
--- sandbox/branches/setuptools-0.6/pkg_resources.py	(original)
+++ sandbox/branches/setuptools-0.6/pkg_resources.py	Mon Oct 12 22:05:56 2009
@@ -20,18 +20,18 @@
 except NameError:
     from sets import ImmutableSet as frozenset
 
-from os import utime, rename, unlink    # capture these to bypass sandboxing
+# capture these to bypass sandboxing
+from os import utime, rename, unlink, mkdir
 from os import open as os_open
+from os.path import isdir, split
 
 
-
-
-
-
-
-
-
-
+def _bypass_ensure_directory(name, mode=0777):
+    # Sandbox-bypassing version of ensure_directory()
+    dirname, filename = split(name)
+    if dirname and filename and not isdir(dirname):
+        _bypass_ensure_directory(dirname)
+        mkdir(dirname, mode)
 
 
 
@@ -957,7 +957,7 @@
         extract_path = self.extraction_path or get_default_cache()
         target_path = os.path.join(extract_path, archive_name+'-tmp', *names)
         try:
-            ensure_directory(target_path)
+            _bypass_ensure_directory(target_path)
         except:
             self.extraction_error()
 

Modified: sandbox/branches/setuptools-0.6/setuptools/archive_util.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/archive_util.py	(original)
+++ sandbox/branches/setuptools-0.6/setuptools/archive_util.py	Mon Oct 12 22:05:56 2009
@@ -189,7 +189,10 @@
                     if dst:
                         if dst.endswith(os.sep):
                             dst = dst[:-1]
-                        tarobj._extract_member(member,dst)  # XXX Ugh
+                        try:
+                            tarobj._extract_member(member,dst)  # XXX Ugh
+                        except tarfile.ExtractError:
+                            pass    # chown/chmod/mkfifo/mknode/makedev failed
         return True
     finally:
         tarobj.close()
@@ -200,6 +203,3 @@
 extraction_drivers = unpack_directory, unpack_zipfile, unpack_tarfile
 
 
-
-
-


More information about the Python-checkins mailing list