@@ -6,7 +6,9 @@ use std::time::{Duration, SystemTime};
6
6
use std:: { env, fs} ;
7
7
8
8
use bitflags:: bitflags;
9
+ #[ cfg( unix) ]
9
10
use nix:: errno:: Errno ;
11
+ #[ cfg( unix) ]
10
12
use nix:: unistd:: { self , Gid , Pid , Uid } ;
11
13
use num_traits:: cast:: ToPrimitive ;
12
14
@@ -176,6 +178,7 @@ fn convert_io_error(vm: &VirtualMachine, err: io::Error) -> PyObjectRef {
176
178
os_error
177
179
}
178
180
181
+ #[ cfg( unix) ]
179
182
fn convert_nix_error ( vm : & VirtualMachine , err : nix:: Error ) -> PyObjectRef {
180
183
let nix_error = match err {
181
184
nix:: Error :: InvalidPath => {
@@ -204,6 +207,7 @@ fn convert_nix_error(vm: &VirtualMachine, err: nix::Error) -> PyObjectRef {
204
207
nix_error
205
208
}
206
209
210
+ #[ cfg( unix) ]
207
211
fn convert_nix_errno ( vm : & VirtualMachine , errno : Errno ) -> PyClassRef {
208
212
match errno {
209
213
Errno :: EPERM => vm. ctx . exceptions . permission_error . clone ( ) ,
@@ -1000,23 +1004,33 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
1000
1004
"supports_follow_symlinks" => supports_follow_symlinks. into_object( ) ,
1001
1005
} ) ;
1002
1006
1003
- if cfg ! ( unix) {
1004
- extend_module ! ( vm, module, {
1005
- "getppid" => ctx. new_rustfunc( os_getppid) ,
1006
- "getgid" => ctx. new_rustfunc( os_getgid) ,
1007
- "getegid" => ctx. new_rustfunc( os_getegid) ,
1008
- "getpgid" => ctx. new_rustfunc( os_getpgid) ,
1009
- "getsid" => ctx. new_rustfunc( os_getsid) ,
1010
- "getuid" => ctx. new_rustfunc( os_getuid) ,
1011
- "geteuid" => ctx. new_rustfunc( os_geteuid) ,
1012
- "setgid" => ctx. new_rustfunc( os_setgid) ,
1013
- "setegid" => ctx. new_rustfunc( os_setegid) ,
1014
- "setpgid" => ctx. new_rustfunc( os_setpgid) ,
1015
- "setsid" => ctx. new_rustfunc( os_setsid) ,
1016
- "setuid" => ctx. new_rustfunc( os_setuid) ,
1017
- "seteuid" => ctx. new_rustfunc( os_seteuid) ,
1018
- } ) ;
1019
- }
1007
+ extend_module_platform_specific ( & vm, module)
1008
+ }
1009
+
1010
+ #[ cfg( unix) ]
1011
+ fn extend_module_platform_specific ( vm : & VirtualMachine , module : PyObjectRef ) -> PyObjectRef {
1012
+ let ctx = & vm. ctx ;
1013
+
1014
+ extend_module ! ( vm, module, {
1015
+ "getppid" => ctx. new_rustfunc( os_getppid) ,
1016
+ "getgid" => ctx. new_rustfunc( os_getgid) ,
1017
+ "getegid" => ctx. new_rustfunc( os_getegid) ,
1018
+ "getpgid" => ctx. new_rustfunc( os_getpgid) ,
1019
+ "getsid" => ctx. new_rustfunc( os_getsid) ,
1020
+ "getuid" => ctx. new_rustfunc( os_getuid) ,
1021
+ "geteuid" => ctx. new_rustfunc( os_geteuid) ,
1022
+ "setgid" => ctx. new_rustfunc( os_setgid) ,
1023
+ "setegid" => ctx. new_rustfunc( os_setegid) ,
1024
+ "setpgid" => ctx. new_rustfunc( os_setpgid) ,
1025
+ "setsid" => ctx. new_rustfunc( os_setsid) ,
1026
+ "setuid" => ctx. new_rustfunc( os_setuid) ,
1027
+ "seteuid" => ctx. new_rustfunc( os_seteuid) ,
1028
+ } ) ;
1029
+
1030
+ module
1031
+ }
1020
1032
1033
+ #[ cfg( not( unix) ) ]
1034
+ fn extend_module_platform_specific ( _vm : & VirtualMachine , module : PyObjectRef ) -> PyObjectRef {
1021
1035
module
1022
1036
}
0 commit comments