[3.6] bpo-29694: race condition in pathlib mkdir with flags parents=True (GH-1089). (GH-1126)

(cherry picked from commit 22a594a004)
This commit is contained in:
Mariatta 2017-04-13 19:26:16 -07:00 committed by GitHub
parent 2cdf087d1f
commit cbc46afa59
3 changed files with 36 additions and 2 deletions

View file

@ -1230,8 +1230,8 @@ class Path(PurePath):
except FileNotFoundError:
if not parents or self.parent == self:
raise
self.parent.mkdir(parents=True)
self._accessor.mkdir(self, mode)
self.parent.mkdir(parents=True, exist_ok=True)
self.mkdir(mode, parents=False, exist_ok=exist_ok)
except OSError:
# Cannot rely on checking for EEXIST, since the operating system
# could give priority to other errors like EACCES or EROFS