From: Antoine Pitrou Date: Mon, 4 May 2009 21:21:36 +0000 (+0000) Subject: Merged revisions 72295 via svnmerge from X-Git-Tag: v3.1b1~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c33e087fc2178c76e76b29cb66d916742075fd4;p=python Merged revisions 72295 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r72295 | antoine.pitrou | 2009-05-04 23:17:17 +0200 (lun., 04 mai 2009) | 3 lines Issue #5692: In :class:`zipfile.Zipfile`, fix wrong path calculation when extracting a file to the root directory. ........ --- diff --git a/Lib/zipfile.py b/Lib/zipfile.py index a54a354d0c..dab595bb7a 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -959,7 +959,9 @@ class ZipFile: """ # 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 diff --git a/Misc/NEWS b/Misc/NEWS index 378ed32749..a92164b9d7 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -112,6 +112,9 @@ Installation 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,