Kaydet (Commit) 0b09c42f authored tarafından Martin v. Löwis's avatar Martin v. Löwis

Issue #6050: Don't fail extracting a directory from a zipfile if

the directory already exists.
üst 53b578eb
...@@ -1023,6 +1023,11 @@ class TestWithDirectory(unittest.TestCase): ...@@ -1023,6 +1023,11 @@ class TestWithDirectory(unittest.TestCase):
self.assertTrue(os.path.isdir(os.path.join(TESTFN2, "a", "b"))) self.assertTrue(os.path.isdir(os.path.join(TESTFN2, "a", "b")))
self.assertTrue(os.path.exists(os.path.join(TESTFN2, "a", "b", "c"))) 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): def testStoreDir(self):
os.mkdir(os.path.join(TESTFN2, "x")) os.mkdir(os.path.join(TESTFN2, "x"))
zipf = zipfile.ZipFile(TESTFN, "w") zipf = zipfile.ZipFile(TESTFN, "w")
......
...@@ -971,7 +971,8 @@ class ZipFile: ...@@ -971,7 +971,8 @@ class ZipFile:
os.makedirs(upperdirs) os.makedirs(upperdirs)
if member.filename[-1] == '/': if member.filename[-1] == '/':
os.mkdir(targetpath) if not os.path.isdir(targetpath):
os.mkdir(targetpath)
return targetpath return targetpath
source = self.open(member, pwd=pwd) source = self.open(member, pwd=pwd)
......
...@@ -302,6 +302,9 @@ Core and Builtins ...@@ -302,6 +302,9 @@ Core and Builtins
Library 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 - Issue #5311: bdist_msi can now build packages that do not depend on a
specific Python version. specific Python version.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment