bpo-29694: race condition in pathlib mkdir with flags parents=True (GH-1089)

This commit is contained in:
Armin Rigo 2017-04-13 20:08:15 +02:00 committed by Mariatta
parent 5908300e4b
commit 22a594a004
3 changed files with 36 additions and 2 deletions

View file

@ -1217,8 +1217,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