@@ -755,6 +755,30 @@ call fails (for example because the path doesn't exist).
755
755
.. versionchanged :: 3.10
756
756
The *follow_symlinks * parameter was added.
757
757
758
+ .. method :: Path.chown(uid, gid, *, dir_fd=None, follow_symlinks=True)
759
+
760
+ Change the file ownership, like :func: `os.chown `.
761
+
762
+ This method normally follows symlinks. Some Unix flavours support changing
763
+ permissions on the symlink itself; on these platforms you may add the
764
+ argument ``follow_symlinks=False ``, or use :meth: `~Path.lchown `.
765
+
766
+ ::
767
+
768
+ >>> p = Path('setup.py')
769
+ >>> p.stat().st_uid
770
+ 1000
771
+ >>> p.stat().st_gid
772
+ 1000
773
+ >>> p.chown(1, 20)
774
+ >>> p.stat().st_uid
775
+ 1
776
+ >>> p.stat().st_gid
777
+ 20
778
+
779
+ .. availability :: Unix.
780
+
781
+
758
782
.. method :: Path.exists()
759
783
760
784
Whether the path points to an existing file or directory::
@@ -923,9 +947,17 @@ call fails (for example because the path doesn't exist).
923
947
symbolic link's mode is changed rather than its target's.
924
948
925
949
950
+ .. method :: Path.lchown(uid, gid, *, dir_fd=None)
951
+
952
+ Like :meth: `Path.chown `, but if the path points to a symbolic link, the
953
+ symbolic link's mode is changed rather than its target's.
954
+
955
+ .. availability :: Unix.
956
+
957
+
926
958
.. method :: Path.lstat()
927
959
928
- Like :meth: `Path.stat ` but, if the path points to a symbolic link, return
960
+ Like :meth: `Path.stat `, but if the path points to a symbolic link, return
929
961
the symbolic link's information rather than its target's.
930
962
931
963
@@ -1260,6 +1292,7 @@ Below is a table mapping various :mod:`os` functions to their corresponding
1260
1292
:func: `os.path.abspath ` :meth: `Path.absolute ` [# ]_
1261
1293
:func: `os.path.realpath ` :meth: `Path.resolve `
1262
1294
:func: `os.chmod ` :meth: `Path.chmod `
1295
+ :func: `os.chown ` :meth: `Path.chown `
1263
1296
:func: `os.mkdir ` :meth: `Path.mkdir `
1264
1297
:func: `os.makedirs ` :meth: `Path.mkdir `
1265
1298
:func: `os.rename ` :meth: `Path.rename `
0 commit comments