forked from Rust-related/RustPython
Replace vm.obj_len to obj.length
This commit is contained in:
@@ -151,7 +151,12 @@ impl PyObjectRef {
|
||||
// int PyObject_TypeCheck(PyObject *o, PyTypeObject *type)
|
||||
|
||||
pub fn length(&self, vm: &VirtualMachine) -> PyResult<usize> {
|
||||
vm.obj_len(self)
|
||||
vm.obj_len_opt(self).unwrap_or_else(|| {
|
||||
Err(vm.new_type_error(format!(
|
||||
"object of type '{}' has no len()",
|
||||
self.class().name()
|
||||
)))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn length_hint(
|
||||
|
||||
@@ -1920,15 +1920,6 @@ impl VirtualMachine {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn obj_len(&self, obj: &PyObjectRef) -> PyResult<usize> {
|
||||
self.obj_len_opt(obj).unwrap_or_else(|| {
|
||||
Err(self.new_type_error(format!(
|
||||
"object of type '{}' has no len()",
|
||||
obj.class().name()
|
||||
)))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn length_hint(&self, iter: PyObjectRef) -> PyResult<Option<usize>> {
|
||||
if let Some(len) = self.obj_len_opt(&iter) {
|
||||
match len {
|
||||
|
||||
Reference in New Issue
Block a user