summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2009-05-24 19:30:52 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2009-05-24 19:30:52 (GMT)
commit0b09c42ffec7b56b7f94c11d160ca083944c9cf8 (patch)
tree3dab68c17b8d22e1ad26666e167118e3dcdca117
parent53b578eba14d377e75ebe7cfd93a644f7ac42057 (diff)
downloadcpython-0b09c42ffec7b56b7f94c11d160ca083944c9cf8.zip
cpython-0b09c42ffec7b56b7f94c11d160ca083944c9cf8.tar.gz
cpython-0b09c42ffec7b56b7f94c11d160ca083944c9cf8.tar.bz2
Issue #6050: Don't fail extracting a directory from a zipfile if
the directory already exists.
-rw-r--r--Lib/test/test_zipfile.py5
-rw-r--r--Lib/zipfile.py3
-rw-r--r--Misc/NEWS3
3 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index fcb55d1..cb8ba10 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -1023,6 +1023,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")
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index e3d40b4..68885f9 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -971,7 +971,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)
diff --git a/Misc/NEWS b/Misc/NEWS
index a21651b..c2f2121 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -302,6 +302,9 @@ Core and Builtins
Library
-------
+- Issue #6050: Don't fail extracting a directory from a zipfile if
+ the directory already exists.
+
- Issue #5311: bdist_msi can now build packages that do not depend on a
specific Python version.