]> granicus.if.org Git - python/commitdiff
Merged revisions 72893 via svnmerge from
authorMartin v. Löwis <martin@v.loewis.de>
Sun, 24 May 2009 19:42:14 +0000 (19:42 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sun, 24 May 2009 19:42:14 +0000 (19:42 +0000)
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 21fc703d4e726372f4e84004d3c01c1b763b838d..1fed79acae1c34fa5b24f23c4b8cce2cb48fb6a6 100644 (file)
@@ -994,6 +994,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 aa88563e5f1cc60bf6ef6f7ac1c3c70c12326a0c..a50a458336146b5b410d6fe06bcc4406a0e5f78d 100644 (file)
@@ -959,7 +959,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 6264e58fa3091b4a180411fd8511c8eeab226b79..1c03d701dfec0cffad8d0a8462397eac2b57c7b7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -50,6 +50,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #6050: Don't fail extracting a directory from a zipfile if
+  the directory already exists.
+
 - Issue #1309352: fcntl now converts its third arguments to a C `long` rather
   than an int, which makes some operations possible under 64-bit Linux (e.g.
   DN_MULTISHOT with F_NOTIFY).