Message81666
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. |
|
Date |
User |
Action |
Args |
2009-02-11 20:36:11 | jab | set | recipients:
+ jab |
2009-02-11 20:36:11 | jab | set | messageid: <1234384571.02.0.296749790343.issue5220@psf.upfronthosting.co.za> |
2009-02-11 20:36:09 | jab | link | issue5220 messages |
2009-02-11 20:36:08 | jab | create | |
|