[issue1675] Race condition in os.makedirs

Isaac Morland report at bugs.python.org
Fri Dec 21 19:25:14 CET 2007


Isaac Morland added the comment:

I should add that the new parameter is called "excl" by analogy with the
O_EXCL option to os.open().

Also, I'm not absolutely certain about the test for which exceptions
should be ignored when excl == False:

e.errno == errno.EEXIST and path.isdir (name)

This will not work if errno is set to something other than EEXIST when
mkdir fails due to the directory already existing.  The above works on
my system but I can't be certain that all mkdir implementations report
EEXIST.

It should be safe to drop the errno check altogether, and I'm starting
to think that we should; at present it's really just an optimization to
avoid using .isdir, but only in what should be rather uncommon
circumstances.  I think the smell of "premature optimization" may be
hard to ignore.

So the if statement would be:

if excl or not path.isdir (name):
    raise

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1675>
__________________________________


More information about the Python-bugs-list mailing list