mirror of
https://github.com/python/cpython.git
synced 2025-08-23 18:24:46 +00:00
bpo-18108: Adding dir_fd and follow_symlinks keyword args to shutil.chown (GH-15811)
* Adding dir_fd and follow_symlinks keyword args to shutil.chown * Extending test_shutil.TestShutil.test_chown to include new kwargs * Updating shutil.chown documentation Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Berker Peksag <berker.peksag@gmail.com> Co-authored-by: Zachary Ware <zachary.ware@gmail.com>
This commit is contained in:
parent
78ba4cb758
commit
8974a63f5e
5 changed files with 53 additions and 4 deletions
|
@ -1442,11 +1442,18 @@ elif _WINDOWS:
|
|||
return _ntuple_diskusage(total, used, free)
|
||||
|
||||
|
||||
def chown(path, user=None, group=None):
|
||||
def chown(path, user=None, group=None, *, dir_fd=None, follow_symlinks=True):
|
||||
"""Change owner user and group of the given path.
|
||||
|
||||
user and group can be the uid/gid or the user/group names, and in that case,
|
||||
they are converted to their respective uid/gid.
|
||||
|
||||
If dir_fd is set, it should be an open file descriptor to the directory to
|
||||
be used as the root of *path* if it is relative.
|
||||
|
||||
If follow_symlinks is set to False and the last element of the path is a
|
||||
symbolic link, chown will modify the link itself and not the file being
|
||||
referenced by the link.
|
||||
"""
|
||||
sys.audit('shutil.chown', path, user, group)
|
||||
|
||||
|
@ -1472,7 +1479,8 @@ def chown(path, user=None, group=None):
|
|||
if _group is None:
|
||||
raise LookupError("no such group: {!r}".format(group))
|
||||
|
||||
os.chown(path, _user, _group)
|
||||
os.chown(path, _user, _group, dir_fd=dir_fd,
|
||||
follow_symlinks=follow_symlinks)
|
||||
|
||||
def get_terminal_size(fallback=(80, 24)):
|
||||
"""Get the size of the terminal window.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue