This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients docs@python, r.david.murray
Date 2011-11-29.13:42:02
SpamBayes Score 3.09053e-10
Marked as misclassified No
Message-id <>
The documentation for os.makedirs says:

  If the target directory with the same mode as specified already exists, raises an OSError exception if exist_ok is False, otherwise no exception is raised.

This is not correct.  If the file exists but the mode is different than that specified (or defaulted) after applying the umask, then an error is raised regardless of the value of exist_ok.  The above wording also implies that if the directory exists but has a different mode, that the mode will be changed.  Again, this is not what the code does.

It's not clear how useful this raise behavior is, but reading the original issue that added this option it is clearly intentional.  The documented behavior does seem useful, but if it actually reset the mode that would be a fairly significant behavior change, and would not be a good idea if the user had not specified a mode.  However, at the very least exists_ok should not raise if no mode was specified in the call.

The error message raised is also wrong in this case, since it says that the error is that the file already exists when we've said that that is OK.  A custom error message for this case would be better.
Date User Action Args
2011-11-29 13:42:03r.david.murraysetrecipients: + r.david.murray, docs@python
2011-11-29 13:42:03r.david.murraysetmessageid: <>
2011-11-29 13:42:02r.david.murraylinkissue13498 messages
2011-11-29 13:42:02r.david.murraycreate