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

(cherry picked from commit 22a594a0047d7706537ff2ac676cdc0f1dcb329c)
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 8c1cb96..70f5cba 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -1230,8 +1230,8 @@
         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