mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-17 01:51:39 +09:00
Merge pull request #611 from RustPython/pyargs
Less explicit PyFuncArgs is better.
This commit is contained in:
@@ -36,13 +36,7 @@ fn filter_next(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
} else {
|
||||
// the predicate itself can raise StopIteration which does stop the filter
|
||||
// iteration
|
||||
vm.invoke(
|
||||
predicate.clone(),
|
||||
PyFuncArgs {
|
||||
args: vec![next_obj.clone()],
|
||||
kwargs: vec![],
|
||||
},
|
||||
)?
|
||||
vm.invoke(predicate.clone(), vec![next_obj.clone()])?
|
||||
};
|
||||
if objbool::boolval(vm, predicate_value)? {
|
||||
return Ok(next_obj);
|
||||
|
||||
@@ -210,13 +210,7 @@ pub fn type_getattribute(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult
|
||||
let attr_class = attr.typ();
|
||||
if attr_class.has_attr("__set__") {
|
||||
if let Some(descriptor) = attr_class.get_attr("__get__") {
|
||||
return vm.invoke(
|
||||
descriptor,
|
||||
PyFuncArgs {
|
||||
args: vec![attr, cls.clone(), mcl],
|
||||
kwargs: vec![],
|
||||
},
|
||||
);
|
||||
return vm.invoke(descriptor, vec![attr, cls.clone(), mcl]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,13 +219,7 @@ pub fn type_getattribute(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult
|
||||
let attr_class = attr.typ();
|
||||
if let Some(descriptor) = attr_class.get_attr("__get__") {
|
||||
let none = vm.get_none();
|
||||
return vm.invoke(
|
||||
descriptor,
|
||||
PyFuncArgs {
|
||||
args: vec![attr, none, cls.clone()],
|
||||
kwargs: vec![],
|
||||
},
|
||||
);
|
||||
return vm.invoke(descriptor, vec![attr, none, cls.clone()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,13 +228,7 @@ pub fn type_getattribute(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult
|
||||
} else if let Some(attr) = mcl.get_attr(&name) {
|
||||
vm.call_get_descriptor(attr, cls.clone())
|
||||
} else if let Some(getter) = cls.get_attr("__getattr__") {
|
||||
vm.invoke(
|
||||
getter,
|
||||
PyFuncArgs {
|
||||
args: vec![mcl, name_str.clone()],
|
||||
kwargs: vec![],
|
||||
},
|
||||
)
|
||||
vm.invoke(getter, vec![mcl, name_str.clone()])
|
||||
} else {
|
||||
let attribute_error = vm.context().exceptions.attribute_error.clone();
|
||||
Err(vm.new_exception(
|
||||
|
||||
Reference in New Issue
Block a user