Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63b91e5

Browse files
committed
Issue #24617: Add comment for os.mkdir about mode quirks
1 parent 39b1025 commit 63b91e5

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Doc/library/os.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,9 +1623,15 @@ features:
16231623

16241624
Create a directory named *path* with numeric mode *mode*.
16251625

1626+
If the directory already exists, :exc:`FileExistsError` is raised.
1627+
1628+
.. _mkdir_modebits:
1629+
16261630
On some systems, *mode* is ignored. Where it is used, the current umask
1627-
value is first masked out. If the directory already exists,
1628-
:exc:`FileExistsError` is raised.
1631+
value is first masked out. If bits other than the last 9 (i.e. the last 3
1632+
digits of the octal representation of the *mode*) are set, their meaning is
1633+
platform-dependent. On some platforms, they are ignored and you should call
1634+
:func:`chmod` explicitly to set them.
16291635

16301636
This function can also support :ref:`paths relative to directory descriptors
16311637
<dir_fd>`.
@@ -1646,8 +1652,8 @@ features:
16461652
Recursive directory creation function. Like :func:`mkdir`, but makes all
16471653
intermediate-level directories needed to contain the leaf directory.
16481654

1649-
The default *mode* is ``0o777`` (octal). On some systems, *mode* is
1650-
ignored. Where it is used, the current umask value is first masked out.
1655+
The *mode* parameter is passed to :func:`mkdir`; see :ref:`the mkdir()
1656+
description <mkdir_modebits>` for how it is interpreted.
16511657

16521658
If *exist_ok* is ``False`` (the default), an :exc:`OSError` is raised if the
16531659
target directory already exists.

0 commit comments

Comments
 (0)