Skip to content

Commit 93eea7c

Browse files
authored
Merge pull request RustPython#1349 from isidentical/seek_constants
add seek constants, resolves RustPython#1348
2 parents c973ed8 + caa4722 commit 93eea7c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

vm/src/stdlib/os.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use nix::errno::Errno;
1212
#[cfg(all(unix, not(target_os = "redox")))]
1313
use nix::pty::openpty;
1414
#[cfg(unix)]
15-
use nix::unistd::{self, Gid, Pid, Uid};
15+
use nix::unistd::{self, Gid, Pid, Uid, Whence};
1616
use num_traits::cast::ToPrimitive;
1717

1818
use bitflags::bitflags;
@@ -1215,6 +1215,9 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) ->
12151215
"access" => ctx.new_rustfunc(os_access),
12161216
"chmod" => ctx.new_rustfunc(os_chmod),
12171217
"ttyname" => ctx.new_rustfunc(os_ttyname),
1218+
"SEEK_SET" => ctx.new_int(Whence::SeekSet as i8),
1219+
"SEEK_CUR" => ctx.new_int(Whence::SeekCur as i8),
1220+
"SEEK_END" => ctx.new_int(Whence::SeekEnd as i8)
12181221
});
12191222

12201223
#[cfg(not(target_os = "redox"))]
@@ -1226,6 +1229,12 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) ->
12261229
"openpty" => ctx.new_rustfunc(os_openpty),
12271230
});
12281231

1232+
#[cfg(not(target_os = "macos"))]
1233+
extend_module!(vm, module, {
1234+
"SEEK_DATA" => ctx.new_int(Whence::SeekData as i8),
1235+
"SEEK_HOLE" => ctx.new_int(Whence::SeekHole as i8)
1236+
});
1237+
12291238
module
12301239
}
12311240

0 commit comments

Comments
 (0)