Repository navigation
Closed
Description
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = 'https://github.com/serhiy-storchaka'
closed_at = <Date 2017-03-24.11:28:49.908>
created_at = <Date 2013-12-08.11:09:05.817>
labels = ['3.7', 'type-bug', 'library']
title = "os.makedirs('dir1/dir2', 0) always fails"
updated_at = <Date 2020-11-16.09:55:44.064>
user = 'https://github.com/serhiy-storchaka'bugs.python.org fields:
activity = <Date 2020-11-16.09:55:44.064>
actor = 'gregory.p.smith'
assignee = 'serhiy.storchaka'
closed = True
closed_date = <Date 2017-03-24.11:28:49.908>
closer = 'serhiy.storchaka'
components = ['Library (Lib)']
creation = <Date 2013-12-08.11:09:05.817>
creator = 'serhiy.storchaka'
dependencies = []
files = ['33043', '33047']
hgrepos = []
issue_num = 19930
keywords = ['patch']
message_count = 7.0
messages = ['205543', '205570', '205581', '268093', '268101', '290082', '381083']
nosy_count = 6.0
nosy_names = ['loewis', 'gregory.p.smith', 'pitrou', 'martin.panter', 'serhiy.storchaka', 'vajrasky']
pr_nums = ['799']
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue19930'
versions = ['Python 3.7']
Activity
serhiy-storchaka commentedon Dec 8, 2013
os.makedirs() can't create a directory with cleared write or list permission bits for owner when parent directories aren't created. This is because for parent directories same mode is used as for final directory.
Note that the mkdir utility creates parent directories with default mode (0o777 & ~umask).
The proposed patch emulates the mkdir utility.
See also bpo-19921.
vajrasky commentedon Dec 8, 2013
Fails on Windows Vista.
======================================================================
FAIL: test_mode (main.MakedirTests)
----------------------------------------------------------------------
Ran 157 tests in 1.865s
The permission of directory on Windows no matter what mode you give or umask you give to support.temp_umask, is always 0o777 (or 511). I think this test does not make sense in Windows.
Either that, or I am missing something.
serhiy-storchaka commentedon Dec 8, 2013
Thank you Vajrasky. Now this check is skipped on Windows.
vadmium commentedon Jun 10, 2016
I’ve never considered this sort of scenario properly, so I don’t know if leaving the default mode for the parent directories is the best way or not. The obvious but more complicated alternative would be to call chmod() on all the new directories in a second step.
Anyway, if we are going to make any change, it should be documented. And I would say the current patch changes behaviour, so is probably not applicable as a bug fix.
serhiy-storchaka commentedon Jun 10, 2016
This is dangerous, because if you create read-only or unlistable directory, you couldn't remove it without changing the permission of parent directory. shutil.rmtree() would fail.
serhiy-storchaka commentedon Mar 24, 2017
New changeset e304e33 by Serhiy Storchaka in branch 'master':
bpo-19930: The mode argument of os.makedirs() no longer affects the file (#799)
e304e33
gpshead commentedon Nov 16, 2020
This API change was not strictly a bugfix, it removed a feature existing code was relying on.
https://bugs.python.org/issue42367 opened to reconcile the two.
vanschelven commentedon Aug 29, 2025
The discussion now continues at