@@ -22,6 +22,7 @@ use nix::pty::openpty;
22
22
use nix:: unistd:: { self , Gid , Pid , Uid } ;
23
23
#[ cfg( unix) ]
24
24
use std:: os:: unix:: io:: RawFd ;
25
+ #[ cfg( unix) ]
25
26
use uname;
26
27
27
28
use super :: errno:: errors;
@@ -1157,6 +1158,7 @@ fn os_urandom(size: usize, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
1157
1158
1158
1159
#[ pystruct_sequence( name = "os.uname_result" ) ]
1159
1160
#[ derive( Debug ) ]
1161
+ #[ cfg( unix) ]
1160
1162
struct UnameResult {
1161
1163
sysname : String ,
1162
1164
nodename : String ,
@@ -1165,6 +1167,7 @@ struct UnameResult {
1165
1167
machine : String ,
1166
1168
}
1167
1169
1170
+ #[ cfg( unix) ]
1168
1171
impl UnameResult {
1169
1172
fn into_obj ( self , vm : & VirtualMachine ) -> PyObjectRef {
1170
1173
self . into_struct_sequence ( vm, vm. class ( "_os" , "uname_result" ) )
@@ -1173,6 +1176,7 @@ impl UnameResult {
1173
1176
}
1174
1177
}
1175
1178
1179
+ #[ cfg( unix) ]
1176
1180
fn os_uname ( vm : & VirtualMachine ) -> PyResult {
1177
1181
let info = uname:: uname ( ) . map_err ( |err| convert_io_error ( vm, err) ) ?;
1178
1182
Ok ( UnameResult {
@@ -1274,7 +1278,6 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
1274
1278
} ) ;
1275
1279
1276
1280
let stat_result = StatResult :: make_class ( ctx) ;
1277
- let uname_result = UnameResult :: make_class ( ctx) ;
1278
1281
1279
1282
struct SupportFunc < ' a > {
1280
1283
name : & ' a str ,
@@ -1363,8 +1366,6 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
1363
1366
"urandom" => ctx. new_function( os_urandom) ,
1364
1367
"isatty" => ctx. new_function( os_isatty) ,
1365
1368
"lseek" => ctx. new_function( os_lseek) ,
1366
- "uname" => ctx. new_function( os_uname) ,
1367
- "uname_result" => uname_result,
1368
1369
1369
1370
"O_RDONLY" => ctx. new_int( libc:: O_RDONLY ) ,
1370
1371
"O_WRONLY" => ctx. new_int( libc:: O_WRONLY ) ,
@@ -1417,6 +1418,9 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
1417
1418
#[ cfg( unix) ]
1418
1419
fn extend_module_platform_specific ( vm : & VirtualMachine , module : PyObjectRef ) -> PyObjectRef {
1419
1420
let ctx = & vm. ctx ;
1421
+
1422
+ let uname_result = UnameResult :: make_class ( ctx) ;
1423
+
1420
1424
extend_module ! ( vm, module, {
1421
1425
"access" => ctx. new_function( os_access) ,
1422
1426
"chmod" => ctx. new_function( os_chmod) ,
@@ -1437,6 +1441,8 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) ->
1437
1441
"setuid" => ctx. new_function( os_setuid) ,
1438
1442
"system" => ctx. new_function( os_system) ,
1439
1443
"ttyname" => ctx. new_function( os_ttyname) ,
1444
+ "uname" => ctx. new_function( os_uname) ,
1445
+ "uname_result" => uname_result,
1440
1446
"EX_OK" => ctx. new_int( exitcode:: OK as i8 ) ,
1441
1447
"EX_USAGE" => ctx. new_int( exitcode:: USAGE as i8 ) ,
1442
1448
"EX_DATAERR" => ctx. new_int( exitcode:: DATAERR as i8 ) ,
0 commit comments