diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 9775040cbe372c..f4dd0fdab4a3e4 100755 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -2411,7 +2411,7 @@ def _extract_member(self, tarinfo, targetpath, set_attrs=True, if upperdirs and not os.path.exists(upperdirs): # Create directories that are not part of the archive with # default permissions. - os.makedirs(upperdirs) + os.makedirs(upperdirs, exist_ok=True) if tarinfo.islnk() or tarinfo.issym(): self._dbg(1, "%s -> %s" % (tarinfo.name, tarinfo.linkname)) diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-04-05-00-48-53.gh-issue-67837.-LJ-2m.rst b/Misc/NEWS.d/next/Core and Builtins/2023-04-05-00-48-53.gh-issue-67837.-LJ-2m.rst new file mode 100644 index 00000000000000..1e8b7ca040ef52 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-04-05-00-48-53.gh-issue-67837.-LJ-2m.rst @@ -0,0 +1 @@ +``tarfile`` - Avoid race condition creating parent directories in when extracting concurrently.