diff options
author | Martin Panter <vadmium+py@gmail.com> | 2015-11-20 02:35:46 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2015-11-20 02:35:46 (GMT) |
commit | 97cabb9fa5bd257aceae724f4727fe54580c4e9f (patch) | |
tree | 59a53473befbf2d38f98e0a0ff0fd634666230d2 /Lib/os.py | |
parent | 82f9feaf1054599fdb37c6c414c7ec2e107ec2da (diff) | |
parent | a82642f9dbdff5253f40d4acee0cbb27aaf34462 (diff) | |
download | cpython-97cabb9fa5bd257aceae724f4727fe54580c4e9f.zip cpython-97cabb9fa5bd257aceae724f4727fe54580c4e9f.tar.gz cpython-97cabb9fa5bd257aceae724f4727fe54580c4e9f.tar.bz2 |
Issue #25583: Merge makedirs fix from 3.4 into 3.5
Diffstat (limited to 'Lib/os.py')
-rw-r--r-- | Lib/os.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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): |