]> granicus.if.org Git - python/commitdiff
Merged revisions 84861 via svnmerge from
authorSenthil Kumaran <orsenthil@gmail.com>
Fri, 17 Sep 2010 16:42:05 +0000 (16:42 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Fri, 17 Sep 2010 16:42:05 +0000 (16:42 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84861 | senthil.kumaran | 2010-09-17 22:05:37 +0530 (Fri, 17 Sep 2010) | 3 lines

  Fix Issue2236: Distutils' mkpath implementation ignoring the "mode" parameter
........

Lib/distutils/dir_util.py
Lib/distutils/tests/test_dir_util.py

index 98e6252c6c7075f3791c725aeb0d5240837b012d..54376e5ca5a3e726a070c81dd55ff12396c0b75c 100644 (file)
@@ -68,7 +68,7 @@ def mkpath(name, mode=0o777, verbose=1, dry_run=0):
 
         if not dry_run:
             try:
-                os.mkdir(head)
+                os.mkdir(head, mode)
                 created_dirs.append(head)
             except OSError as exc:
                 raise DistutilsFileError(
index 0f694aa0202a9523a2e4a2513aa89afbd12787c0..8986ca55d4e00b6f35ce74f022409cf6c67a2d6e 100644 (file)
@@ -1,6 +1,7 @@
 """Tests for distutils.dir_util."""
 import unittest
 import os
+import stat
 import shutil
 
 from distutils.dir_util import (mkpath, remove_tree, create_tree, copy_tree,
@@ -48,6 +49,12 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
         wanted = ["removing '%s' (and everything under it)" % self.root_target]
         self.assertEquals(self._logs, wanted)
 
+    def test_mkpath_with_custom_mode(self):
+        mkpath(self.target, 0o700)
+        self.assertEqual(stat.S_IMODE(os.stat(self.target).st_mode), 0o700)
+        mkpath(self.target2, 0o555)
+        self.assertEqual(stat.S_IMODE(os.stat(self.target2).st_mode), 0o555)
+
     def test_create_tree_verbosity(self):
 
         create_tree(self.root_target, ['one', 'two', 'three'], verbose=0)