Skip to content

Commit a0521bc

Browse files
committed
Merge branch 'master' of https://github.com/RustPython/RustPython into extend-socket
2 parents 70d9e43 + e0de5fc commit a0521bc

File tree

7 files changed

+24
-15
lines changed

7 files changed

+24
-15
lines changed

tests/benchmarks/perf_add.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
j = 0
22
while j < 1000:
3-
43
total = 0
54
i = 0
65
while i < 100:
76
total += i
87
i += 1
9-
# print(total)
10-
118
j += 1

tests/benchmarks/perf_fib.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
def fib(n):
2-
# a, b = 1, 1
32
a = 1
43
b = 1
5-
for _ in range(n-1):
4+
for _ in range(n - 1):
65
temp = b
7-
b = a+b
6+
b = a + b
87
a = temp
98

10-
#a, b = b, a+b
119
return b
1210

1311
print(fib(1))
1412
print(fib(2))
1513
print(fib(3))
1614
print(fib(4))
17-
print(fib(5))
15+
print(fib(5))

tests/snippets/bools.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ def __bool__(self):
8080
assert False.__rxor__(0) is not False
8181
assert False.__rxor__(False) is False
8282

83+
assert True.real == 1
84+
assert True.imag == 0
85+
assert type(True.real) is int
86+
assert type(True.imag) is int
87+
8388
# Check work for sequence and map
8489
assert bool({}) is False
8590
assert bool([]) is False

tests/snippets/stdlib_os.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ def __exit__(self, exc_type, exc_val, exc_tb):
233233
os.stat(fname, follow_symlinks=False).st_mode == os.stat(symlink_file, follow_symlinks=False).st_mode
234234

235235
# os.chmod
236-
os.chmod(fname, 0o666)
237-
assert oct(os.stat(fname).st_mode) == '0o100666'
236+
if os.name != "nt":
237+
os.chmod(fname, 0o666)
238+
assert oct(os.stat(fname).st_mode) == '0o100666'
238239

239240
# os.path
240241
assert os.path.exists(fname) == True

vm/src/obj/objbool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ The class bool is a subclass of the class int, and cannot be subclassed.";
7777
"__rand__" => context.new_rustfunc(bool_rand),
7878
"__xor__" => context.new_rustfunc(bool_xor),
7979
"__rxor__" => context.new_rustfunc(bool_rxor),
80-
"__doc__" => context.new_str(bool_doc.to_string())
80+
"__doc__" => context.new_str(bool_doc.to_string()),
8181
});
8282
}
8383

vm/src/obj/objint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,8 @@ impl PyInt {
681681
Ok(PyBytes::new(bytes))
682682
}
683683
#[pyproperty]
684-
fn real(zelf: PyRef<Self>, _vm: &VirtualMachine) -> PyIntRef {
685-
zelf
684+
fn real(&self, vm: &VirtualMachine) -> PyObjectRef {
685+
vm.ctx.new_int(self.value.clone())
686686
}
687687

688688
#[pyproperty]

vm/src/stdlib/os.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,12 +1096,11 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
10961096
}
10971097
}
10981098
}
1099-
let support_funcs = vec![
1099+
let mut support_funcs = vec![
11001100
SupportFunc::new(vm, "open", os_open, None, Some(false), None),
11011101
// access Some Some None
11021102
SupportFunc::new(vm, "chdir", os_chdir, Some(false), None, None),
11031103
// chflags Some, None Some
1104-
SupportFunc::new(vm, "chmod", os_chmod, Some(false), Some(false), Some(false)),
11051104
// chown Some Some Some
11061105
// chroot Some None None
11071106
SupportFunc::new(vm, "listdir", os_listdir, Some(false), None, None),
@@ -1121,6 +1120,15 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
11211120
SupportFunc::new(vm, "unlink", os_remove, Some(false), Some(false), None),
11221121
// utime Some Some Some
11231122
];
1123+
#[cfg(unix)]
1124+
support_funcs.extend(vec![SupportFunc::new(
1125+
vm,
1126+
"chmod",
1127+
os_chmod,
1128+
Some(false),
1129+
Some(false),
1130+
Some(false),
1131+
)]);
11241132
let supports_fd = PySet::default().into_ref(vm);
11251133
let supports_dir_fd = PySet::default().into_ref(vm);
11261134
let supports_follow_symlinks = PySet::default().into_ref(vm);

0 commit comments

Comments
 (0)