Skip to content

Commit

Permalink
Merged revisions 72893 via svnmerge from
Browse files Browse the repository at this point in the history
svn+ssh://[email protected]/python/trunk

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

  Issue python#6050: Don't fail extracting a directory from a zipfile if
  the directory already exists.
........
  • Loading branch information
loewis committed May 24, 2009
1 parent 403117a commit 70ccd16
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Lib/test/test_zipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,11 @@ def testExtractDir(self):
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")
Expand Down
3 changes: 2 additions & 1 deletion Lib/zipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,8 @@ def _extract_member(self, member, targetpath, pwd):
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)
Expand Down
3 changes: 3 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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).
Expand Down

0 comments on commit 70ccd16

Please sign in to comment.