Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc3f81e

Browse files
committed
gh-112998: zipfile: fix extractall makedirs race condition
1 parent 3251ba8 commit dc3f81e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Lib/zipfile/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,11 +1781,11 @@ def _extract_member(self, member, targetpath, pwd):
17811781
# Create all upper directories if necessary.
17821782
upperdirs = os.path.dirname(targetpath)
17831783
if upperdirs and not os.path.exists(upperdirs):
1784-
os.makedirs(upperdirs)
1784+
os.makedirs(upperdirs, exist_ok=True)
17851785

17861786
if member.is_dir():
17871787
if not os.path.isdir(targetpath):
1788-
os.mkdir(targetpath)
1788+
os.mkdir(targetpath, exist_ok=True)
17891789
return targetpath
17901790

17911791
with self.open(member, pwd=pwd) as source, \
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
`zipfile`` - Avoid race condition creating parent directories when
2+
extracting concurrently.

0 commit comments

Comments
 (0)