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.

classification
Title: os.makedirs() ignores mode parameter
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ajung, calvin, georg.brandl
Priority: normal Keywords:

Created on 2005-01-21 09:42 by ajung, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg24014 - (view) Author: Andreas Jung (ajung) Date: 2005-01-21 09:42
os.makedirs('foo/x', 0777) does not create the directories
with permissions g+rwx,u+rwx,o+rwx but instead:

>>> import os
>>> os.makedirs('foo/xx', 0777)
>>>
[2]+  Stopped                 python2.3
ajung@hrs2dev2:~/sandboxes/haufecms/instance/Products/HaufeCMS:
ls -la foo
insgesamt 12
drwxr-xr-x   3 ajung ajung 4096 2005-01-21 10:39 .
drwxr-xr-x  19 ajung ajung 4096 2005-01-21 10:39 ..
drwxr-xr-x   2 ajung ajung 4096 2005-01-21 10:39 xx


This happens with Python 2.3.4 on Linux
msg24015 - (view) Author: Bastian Kleineidam (calvin) Date: 2005-01-24 12:48
Logged In: YES 
user_id=9205

What is the current process umask? The resulting directory
mode will always be (mode &  ~umask  &  0777).
To be sure that os.makedirs() will use the given mode
without modification, you have to execute os.umask(0)
beforehand.

So this bug is probably invalid if you forgot to set your
umask accordingly.
msg24016 - (view) Author: Andreas Jung (ajung) Date: 2005-01-26 13:22
Logged In: YES 
user_id=11084

umask(0) does the job. In this case the documentation is
completely misleading. The API reads as the 'mode' parameter
is *the* umask.
msg24017 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-12-17 17:15
Logged In: YES 
user_id=1188172

Clarified the docs in rev. 41732/41733.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41472
2005-01-21 09:42:50ajungcreate