diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-24 11:27:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-24 11:27:42 (GMT) |
commit | e304e33c16e060932d1e2cc8a030d42b02b429b5 (patch) | |
tree | d6c763564bfa27d2e4069a980296e90c8f71f31f /Lib | |
parent | 5619ab2db3a6c62ffaa55e8826cf67b7459fc484 (diff) | |
download | cpython-e304e33c16e060932d1e2cc8a030d42b02b429b5.zip cpython-e304e33c16e060932d1e2cc8a030d42b02b429b5.tar.gz cpython-e304e33c16e060932d1e2cc8a030d42b02b429b5.tar.bz2 |
bpo-19930: The mode argument of os.makedirs() no longer affects the file (#799)
permission bits of newly-created intermediate-level directories.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/os.py | 2 | ||||
-rw-r--r-- | Lib/test/test_os.py | 12 |
2 files changed, 13 insertions, 1 deletions
@@ -207,7 +207,7 @@ def makedirs(name, mode=0o777, exist_ok=False): head, tail = path.split(head) if head and tail and not path.exists(head): try: - makedirs(head, mode, exist_ok) + makedirs(head, exist_ok=exist_ok) except FileExistsError: # Defeats race condition when another thread created the path pass diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 5f302f6..83932e6 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -1118,6 +1118,18 @@ class MakedirTests(unittest.TestCase): 'dir5', 'dir6') os.makedirs(path) + def test_mode(self): + with support.temp_umask(0o002): + base = support.TESTFN + parent = os.path.join(base, 'dir1') + path = os.path.join(parent, 'dir2') + os.makedirs(path, 0o555) + self.assertTrue(os.path.exists(path)) + self.assertTrue(os.path.isdir(path)) + if os.name != 'nt': + self.assertEqual(stat.S_IMODE(os.stat(path).st_mode), 0o555) + self.assertEqual(stat.S_IMODE(os.stat(parent).st_mode), 0o775) + def test_exist_ok_existing_directory(self): path = os.path.join(support.TESTFN, 'dir1') mode = 0o777 |