Skip to content

Commit 3d4fd5f

Browse files
authored
Merge pull request RustPython#456 from yuvipanda/os-name
Implement os.name
2 parents c6c1e7f + 252c3be commit 3d4fd5f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

tests/snippets/os_info.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import os
2+
3+
assert os.name == 'posix'

vm/src/stdlib/os.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,13 @@ pub fn mk_module(ctx: &PyContext) -> PyObjectRef {
121121
ctx.set_attr(&py_mod, "O_NONBLOCK", ctx.new_int(4));
122122
ctx.set_attr(&py_mod, "O_APPEND", ctx.new_int(8));
123123
ctx.set_attr(&py_mod, "O_CREAT", ctx.new_int(512));
124+
125+
if cfg!(windows) {
126+
ctx.set_attr(&py_mod, "name", ctx.new_str("nt".to_string()));
127+
} else {
128+
// Assume we're on a POSIX system
129+
ctx.set_attr(&py_mod, "name", ctx.new_str("posix".to_string()));
130+
}
131+
124132
py_mod
125133
}

0 commit comments

Comments
 (0)