Merge branch 'master' of https://github.com/RustPython/RustPython into extend-socket

This commit is contained in:
lynskylate
2019-08-22 22:22:03 +08:00
7 changed files with 24 additions and 15 deletions

View File

@@ -1,11 +1,8 @@
j = 0
while j < 1000:
total = 0
i = 0
while i < 100:
total += i
i += 1
# print(total)
j += 1

View File

@@ -1,17 +1,15 @@
def fib(n):
# a, b = 1, 1
a = 1
b = 1
for _ in range(n-1):
for _ in range(n - 1):
temp = b
b = a+b
b = a + b
a = temp
#a, b = b, a+b
return b
print(fib(1))
print(fib(2))
print(fib(3))
print(fib(4))
print(fib(5))
print(fib(5))

View File

@@ -80,6 +80,11 @@ assert False.__xor__(False) is False
assert False.__rxor__(0) is not False
assert False.__rxor__(False) is False
assert True.real == 1
assert True.imag == 0
assert type(True.real) is int
assert type(True.imag) is int
# Check work for sequence and map
assert bool({}) is False
assert bool([]) is False

View File

@@ -233,8 +233,9 @@ with TestWithTempDir() as tmpdir:
os.stat(fname, follow_symlinks=False).st_mode == os.stat(symlink_file, follow_symlinks=False).st_mode
# os.chmod
os.chmod(fname, 0o666)
assert oct(os.stat(fname).st_mode) == '0o100666'
if os.name != "nt":
os.chmod(fname, 0o666)
assert oct(os.stat(fname).st_mode) == '0o100666'
# os.path
assert os.path.exists(fname) == True

View File

@@ -77,7 +77,7 @@ The class bool is a subclass of the class int, and cannot be subclassed.";
"__rand__" => context.new_rustfunc(bool_rand),
"__xor__" => context.new_rustfunc(bool_xor),
"__rxor__" => context.new_rustfunc(bool_rxor),
"__doc__" => context.new_str(bool_doc.to_string())
"__doc__" => context.new_str(bool_doc.to_string()),
});
}

View File

@@ -681,8 +681,8 @@ impl PyInt {
Ok(PyBytes::new(bytes))
}
#[pyproperty]
fn real(zelf: PyRef<Self>, _vm: &VirtualMachine) -> PyIntRef {
zelf
fn real(&self, vm: &VirtualMachine) -> PyObjectRef {
vm.ctx.new_int(self.value.clone())
}
#[pyproperty]

View File

@@ -1096,12 +1096,11 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
}
}
}
let support_funcs = vec![
let mut support_funcs = vec![
SupportFunc::new(vm, "open", os_open, None, Some(false), None),
// access Some Some None
SupportFunc::new(vm, "chdir", os_chdir, Some(false), None, None),
// chflags Some, None Some
SupportFunc::new(vm, "chmod", os_chmod, Some(false), Some(false), Some(false)),
// chown Some Some Some
// chroot Some None None
SupportFunc::new(vm, "listdir", os_listdir, Some(false), None, None),
@@ -1121,6 +1120,15 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
SupportFunc::new(vm, "unlink", os_remove, Some(false), Some(false), None),
// utime Some Some Some
];
#[cfg(unix)]
support_funcs.extend(vec![SupportFunc::new(
vm,
"chmod",
os_chmod,
Some(false),
Some(false),
Some(false),
)]);
let supports_fd = PySet::default().into_ref(vm);
let supports_dir_fd = PySet::default().into_ref(vm);
let supports_follow_symlinks = PySet::default().into_ref(vm);