@@ -940,7 +940,13 @@ pub mod module {
940
940
vm : & VirtualMachine ,
941
941
) -> PyResult < ( ) > {
942
942
match path {
943
- OsPathOrFd :: Path ( path) => _chmod ( path, dir_fd, mode, follow_symlinks, vm) ,
943
+ OsPathOrFd :: Path ( path) => {
944
+ #[ cfg( any( target_os = "macos" , target_os = "freebsd" , target_os = "netbsd" , ) ) ]
945
+ if !follow_symlinks. 0 && dir_fd == Default :: default ( ) {
946
+ return lchmod ( path, mode, vm) ;
947
+ }
948
+ _chmod ( path, dir_fd, mode, follow_symlinks, vm)
949
+ }
944
950
OsPathOrFd :: Fd ( fd) => _fchmod ( fd, mode, vm) ,
945
951
}
946
952
}
@@ -963,7 +969,7 @@ pub mod module {
963
969
_fchmod ( fd, mode, vm)
964
970
}
965
971
966
- #[ cfg( not ( target_os = "redox" ) ) ]
972
+ #[ cfg( any ( target_os = "macos" , target_os = "freebsd" , target_os = "netbsd" , ) ) ]
967
973
#[ pyfunction]
968
974
fn lchmod ( path : OsPath , mode : u32 , vm : & VirtualMachine ) -> PyResult < ( ) > {
969
975
extern "C" {
@@ -1700,7 +1706,22 @@ pub mod module {
1700
1706
1701
1707
pub ( crate ) fn support_funcs ( ) -> Vec < SupportFunc > {
1702
1708
vec ! [
1703
- SupportFunc :: new( "chmod" , Some ( false ) , Some ( false ) , Some ( false ) ) ,
1709
+ SupportFunc :: new(
1710
+ "chmod" ,
1711
+ Some ( false ) ,
1712
+ Some ( false ) ,
1713
+ Some (
1714
+ if cfg!( any(
1715
<
815B
/td>+ target_os = "macos" ,
1716
+ target_os = "freebsd" ,
1717
+ target_os = "netbsd"
1718
+ ) ) {
1719
+ true
1720
+ } else {
1721
+ false
1722
+ } ,
1723
+ ) ,
1724
+ ) ,
1704
1725
#[ cfg( not( target_os = "redox" ) ) ]
1705
1726
SupportFunc :: new( "chroot" , Some ( false ) , None , None ) ,
1706
1727
#[ cfg( not( target_os = "redox" ) ) ]
0 commit comments