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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update docs.
  • Loading branch information
serhiy-storchaka committed Dec 13, 2023
commit 62a69c9a57753b28423dbe5f372f5c153f42c1df
17 changes: 12 additions & 5 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ as internal buffering of data.
docs for :func:`chmod` for possible values of *mode*. As of Python 3.3, this
is equivalent to ``os.chmod(fd, mode)``.

.. audit-event:: os.chmod path,mode,dir_fd os.fchmod
.. audit-event:: os.chmod path,mode,dir_fd,follow_symlinks os.fchmod

.. availability:: Unix.

Expand Down Expand Up @@ -2027,7 +2027,7 @@ features:
Accepts a :term:`path-like object`.


.. function:: chmod(path, mode, *, dir_fd=None, follow_symlinks=True)
.. function:: chmod(path, mode, *, dir_fd=None, follow_symlinks=(os.name != 'nt'))

Change the mode of *path* to the numeric *mode*. *mode* may take one of the
following values (as defined in the :mod:`stat` module) or bitwise ORed
Expand Down Expand Up @@ -2062,11 +2062,12 @@ features:
Although Windows supports :func:`chmod`, you can only set the file's
read-only flag with it (via the ``stat.S_IWRITE`` and ``stat.S_IREAD``
constants or a corresponding integer value). All other bits are ignored.
By default, :func:`chmod` on Windows does not follow symlinks.

The function is limited on Emscripten and WASI, see
:ref:`wasm-availability` for more information.

.. audit-event:: os.chmod path,mode,dir_fd os.chmod
.. audit-event:: os.chmod path,mode,dir_fd,follow_symlinks os.chmod

.. versionadded:: 3.3
Added support for specifying *path* as an open file descriptor,
Expand All @@ -2075,6 +2076,9 @@ features:
.. versionchanged:: 3.6
Accepts a :term:`path-like object`.

.. versionchanged:: 3.13
Added support for the *follow_symlinks* argument on Windows.


.. function:: chown(path, uid, gid, *, dir_fd=None, follow_symlinks=True)

Expand Down Expand Up @@ -2160,13 +2164,16 @@ features:
for possible values of *mode*. As of Python 3.3, this is equivalent to
``os.chmod(path, mode, follow_symlinks=False)``.

.. audit-event:: os.chmod path,mode,dir_fd os.lchmod
.. audit-event:: os.chmod path,mode,dir_fd,follow_symlinks os.lchmod

.. availability:: Unix.
.. availability:: Unix, Windows.

.. versionchanged:: 3.6
Accepts a :term:`path-like object`.

.. versionchanged:: 3.13
Added support on Windows.

.. function:: lchown(path, uid, gid)

Change the owner and group id of *path* to the numeric *uid* and *gid*. This
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add support of :func:`os.lchmod` and the *follow_symlinks* argument in
:func:`os.chmod` on Windows.
2 changes: 1 addition & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3531,7 +3531,7 @@ os_fchmod_impl(PyObject *module, int fd, int mode)
int res;
int async_err = 0;

if (PySys_Audit("os.chmod", "iii", fd, mode, -1) < 0) {
if (PySys_Audit("os.chmod", "iiiO", fd, mode, -1, Py_False) < 0) {
return NULL;
}

Expand Down