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 jab
Recipients jab
Date 2009-02-11.20:36:08
SpamBayes Score 9.0978865e-08
Marked as misclassified No
Message-id <1234384571.02.0.296749790343.issue5220@psf.upfronthosting.co.za>
In-reply-to
Content
os.makedirs' mode argument defaults to a hardcoded value of 511 (0777 in 
octal). This forces the caller to either pass in a different hardcoded value 
(commonly 0750), or to implement a workaround that calculates the expected 
mode based on the process owner's umask:

    umask, _ = subprocess.Popen(['sh', '-c', 'umask'],
                   stdout=subprocess.PIPE).communicate()
    umask = int(umask, 8)
    mode = 0777 ^ umask
    os.makedirs(dir, mode)

Preferred behavior would be to have the mode default to the value which 
takes the umask into account rather than the hardcoded value 0777, so that 
directories would be created with the same permissions as e.g. files created 
via open(..).

N.B. I'm guessing the above workaround won't work on Windows (please excuse 
my poor Windows knowledge). All the more reason to have os.makedirs 
calculate the mode properly if none is given.
History
Date User Action Args
2009-02-11 20:36:11jabsetrecipients: + jab
2009-02-11 20:36:11jabsetmessageid: <1234384571.02.0.296749790343.issue5220@psf.upfronthosting.co.za>
2009-02-11 20:36:09jablinkissue5220 messages
2009-02-11 20:36:08jabcreate