diff options
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/test/test_zipfile.py | 5 | ||||
| -rw-r--r-- | Lib/zipfile.py | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 21fc703..1fed79a 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -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") diff --git a/Lib/zipfile.py b/Lib/zipfile.py index aa88563..a50a458 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -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) |
