[issue1675] Race condition in os.makedirs

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


Isaac Morland added the comment:

Attached is an svn diff against the trunk.  I was looking at os.py from
Python 2.5 not the trunk, and it appears that an attempt at fixing the
race condition has already been put into os.py, but I don't believe it's
correct.

The attached patch renames the existing mkdir to _mkdir, and creates a
new mkdir with an additional "excl" parameter to select
error-if-already-exists or not.  It defaults to the current behaviour. 
Similarly, makedirs gets the same extra parameter which is passed down
to mkdir.

By simply using the new versions as before, one obtains the old
behaviour unchanged except that the race condition is corrected.  By
using excl=False one gets the new behaviour.

I have updated the documentation also but I don't really know what I'm
doing there so my use of the rst format may not be right.

Added file: http://bugs.python.org/file9022/patch.txt

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1675>
__________________________________
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.txt
Url: http://mail.python.org/pipermail/python-bugs-list/attachments/20071221/2c4ae6f7/attachment-0001.txt 


More information about the Python-bugs-list mailing list