]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 72895 via svnmerge from
authorMartin v. Löwis <martin@v.loewis.de>
Sun, 24 May 2009 19:53:33 +0000 (19:53 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sun, 24 May 2009 19:53:33 +0000 (19:53 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r72895 | martin.v.loewis | 2009-05-24 21:47:22 +0200 (So, 24 Mai 2009) | 10 lines

  Merged revisions 72893 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r72893 | martin.v.loewis | 2009-05-24 21:30:52 +0200 (So, 24 Mai 2009) | 3 lines

    Issue #6050: Don't fail extracting a directory from a zipfile if
    the directory already exists.
  ........
................

Lib/test/test_zipfile.py
Lib/zipfile.py
Misc/NEWS

index c85d21d0074d3fc3e760507fe4c78853ec021124..6865fabfa1e8b1636c4b03eeb1c6bba325e90ae1 100644 (file)
@@ -983,6 +983,11 @@ class TestWithDirectory(unittest.TestCase):
         self.assertTrue(os.path.isdir(os.path.join(TESTFN2, "a", "b")))
         self.assertTrue(os.path.exists(os.path.join(TESTFN2, "a", "b", "c")))
 
+    def test_bug_6050(self):
+        # Extraction should succeed if directories already exist
+        os.mkdir(os.path.join(TESTFN2, "a"))
+        self.testExtractDir()
+
     def testStoreDir(self):
         os.mkdir(os.path.join(TESTFN2, "x"))
         zipf = zipfile.ZipFile(TESTFN, "w")
index 661128ee15ca028c8693edb15cfc0a80e5262a4d..d2911e1184e4cc35c16b44e6df7c212687b81b5d 100644 (file)
@@ -964,7 +964,8 @@ class ZipFile:
             os.makedirs(upperdirs)
 
         if member.filename[-1] == '/':
-            os.mkdir(targetpath)
+            if not os.path.isdir(targetpath):
+                os.mkdir(targetpath)
             return targetpath
 
         source = self.open(member, pwd=pwd)
index bc5b3e9b11d6faf515d84e5d3da8dd41c29cbc37..9dad57fc62737336babc2f05a6f1a549628f0218 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -65,6 +65,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #6050: Don't fail extracting a directory from a zipfile if
+  the directory already exists.
+
 - Issue #5259: smtplib plain auth login no longer gives a traceback.  Fix
   by Musashi Tamura, tests by Marcin Bachry.