summaryrefslogtreecommitdiff
path: root/Lib/os.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-11-20 02:37:29 +0000
committerMartin Panter <vadmium+py@gmail.com>2015-11-20 02:37:29 +0000
commit5e02af4961ed6278cd8e9aa4a59902fa4b16c8cb (patch)
tree1d907d1738d50b41ce084eb44e4ef94fb87b5354 /Lib/os.py
parent13d9b86d467539fac30370e0c87ee34683fd9721 (diff)
parent97cabb9fa5bd257aceae724f4727fe54580c4e9f (diff)
downloadcpython-git-5e02af4961ed6278cd8e9aa4a59902fa4b16c8cb.tar.gz
Issue #25583: Merge makedirs fix from 3.5
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/os.py b/Lib/os.py
index 3d2c6d3d49..2b89b93d63 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -230,7 +230,7 @@ def makedirs(name, mode=0o777, exist_ok=False):
try:
makedirs(head, mode, exist_ok)
except FileExistsError:
- # be happy if someone already created the path
+ # Defeats race condition when another thread created the path
pass
cdir = curdir
if isinstance(tail, bytes):
@@ -239,8 +239,10 @@ def makedirs(name, mode=0o777, exist_ok=False):
return
try:
mkdir(name, mode)
- except OSError as e:
- if not exist_ok or e.errno != errno.EEXIST or not path.isdir(name):
+ except OSError:
+ # Cannot rely on checking for EEXIST, since the operating system
+ # could give priority to other errors like EACCES or EROFS
+ if not exist_ok or not path.isdir(name):
raise
def removedirs(name):