[Python-checkins] r72295 - in python/trunk: Lib/zipfile.py Misc/NEWS

antoine.pitrou python-checkins at python.org
Mon May 4 23:17:17 CEST 2009


Author: antoine.pitrou
Date: Mon May  4 23:17:17 2009
New Revision: 72295

Log:
Issue #5692: In :class:`zipfile.Zipfile`, fix wrong path calculation when extracting a file to the root directory.



Modified:
   python/trunk/Lib/zipfile.py
   python/trunk/Misc/NEWS

Modified: python/trunk/Lib/zipfile.py
==============================================================================
--- python/trunk/Lib/zipfile.py	(original)
+++ python/trunk/Lib/zipfile.py	Mon May  4 23:17:17 2009
@@ -952,7 +952,9 @@
         """
         # build the destination pathname, replacing
         # forward slashes to platform specific separators.
-        if targetpath[-1:] in (os.path.sep, os.path.altsep):
+        # Strip trailing path separator, unless it represents the root.
+        if (targetpath[-1:] in (os.path.sep, os.path.altsep)
+            and len(os.path.splitdrive(targetpath)[1]) > 1):
             targetpath = targetpath[:-1]
 
         # don't include leading "/" from file name if present

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Mon May  4 23:17:17 2009
@@ -269,6 +269,9 @@
 Library
 -------
 
+- Issue #5692: In :class:`zipfile.Zipfile`, fix wrong path calculation when
+  extracting a file to the root directory.
+
 - Issue #5913: os.listdir() should fail for empty path on windows.
 
 - Issue #5084: unpickling now interns the attribute names of pickled objects,


More information about the Python-checkins mailing list