Johannes Kolb <johannes.k...@gmx.net> added the comment: I want to mention a situation in which the current behaviour of os.makedirs is confusing. At the first glance I would expect that if >>> os.makedirs(path) succeeds, then a following call to >>> os.makedirs(path, exist_ok=True) will succeed too.
This is not always the case. Consider this (assuming Linux as OS and the umask set to 0o022): >>> os.makedirs('/tmp/mytest') >>> os.chmod('/tmp/mytest', 0o2755) >>> path='/tmp/mytest/dir1' >>> os.makedirs(path) >>> os.makedirs(path, exist_ok=True) OSError: [Errno 17] File exists: '/tmp/mytest/dir1' The directory '/tmp/mytest' here has the SETGID flag set, which is inherited automatically. Therefore the flags of '/tmp/mytest/dir1' are not 0o755 as expected by os.makedirs, but 0o2755. The same problem occurs if the user can changes the umask between the calls to os.makedirs. I wonder in what situation the current behaviour of os.makedirs is really helpful and not introducing subtle bugs. Consider using os.makedirs to ensure that the output directory of your script exists. Now the user decides to make this output directory world writeable. For most cases this is no problem, but os.makedirs will complain. ---------- nosy: +jokoala _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13498> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com