From ba7209f0a5a495189c7e3267d8d0459f38b312be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sat, 6 Nov 2010 04:48:05 +0000 Subject: [PATCH] Prevent race condition with mkdir in distutils. Patch by Arfrever on #9281. --- Lib/distutils/dir_util.py | 7 ++++--- Misc/NEWS | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/distutils/dir_util.py b/Lib/distutils/dir_util.py index 54376e5ca5a..c7c9fccfd79 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 diff --git a/Misc/NEWS b/Misc/NEWS index 0d3867e7d5a..44458521e08 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -65,6 +65,9 @@ Core and Builtins Library ------- +- Issue #9281: Prevent race condition with mkdir in distutils. Patch by + Arfrever. + - Issue #10229: Fix caching error in gettext. - Issue #10252: Close file objects in a timely manner in distutils code and