diff options
author | Éric Araujo <merwok@netwok.org> | 2010-11-06 04:48:05 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2010-11-06 04:48:05 (GMT) |
commit | ba7209f0a5a495189c7e3267d8d0459f38b312be (patch) | |
tree | c6a9a7ae04820b4d21aee635efd82c9a3f9cfec5 /Lib/distutils/dir_util.py | |
parent | 909ddbd19347dcd19d9065d6e11f60a956dc54ef (diff) | |
download | cpython-ba7209f0a5a495189c7e3267d8d0459f38b312be.zip cpython-ba7209f0a5a495189c7e3267d8d0459f38b312be.tar.gz cpython-ba7209f0a5a495189c7e3267d8d0459f38b312be.tar.bz2 |
Prevent race condition with mkdir in distutils. Patch by Arfrever on #9281.
Diffstat (limited to 'Lib/distutils/dir_util.py')
-rw-r--r-- | Lib/distutils/dir_util.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/distutils/dir_util.py b/Lib/distutils/dir_util.py index 54376e5..c7c9fcc 100644 --- a/Lib/distutils/dir_util.py +++ b/Lib/distutils/dir_util.py @@ -69,10 +69,11 @@ def mkpath(name, mode=0o777, verbose=1, dry_run=0): if not dry_run: try: os.mkdir(head, mode) - created_dirs.append(head) except OSError as exc: - raise DistutilsFileError( - "could not create '%s': %s" % (head, exc.args[-1])) + if not (exc.errno == errno.EEXIST and os.path.isdir(head)): + raise DistutilsFileError( + "could not create '%s': %s" % (head, exc.args[-1])) + created_dirs.append(head) _path_created[abs_head] = 1 return created_dirs |