Skip to content

Commit 32e693f

Browse files
committed
Replace vm.obj_len to obj.length
1 parent 6b14756 commit 32e693f

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

vm/src/protocol/object.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ impl PyObjectRef {
151151
// int PyObject_TypeCheck(PyObject *o, PyTypeObject *type)
152152

153153
pub fn length(&self, vm: &VirtualMachine) -> PyResult<usize> {
154-
vm.obj_len(self)
154+
vm.obj_len_opt(self).unwrap_or_else(|| {
155+
Err(vm.new_type_error(format!(
156+
"object of type '{}' has no len()",
157+
self.class().name()
158+
)))
159+
})
155160
}
156161

157162
pub fn length_hint(

vm/src/vm.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,15 +1920,6 @@ impl VirtualMachine {
19201920
})
19211921
}
19221922

1923-
pub fn obj_len(&self, obj: &PyObjectRef) -> PyResult<usize> {
1924-
self.obj_len_opt(obj).unwrap_or_else(|| {
1925-
Err(self.new_type_error(format!(
1926-
"object of type '{}' has no len()",
1927-
obj.class().name()
1928-
)))
1929-
})
1930-
}
1931-
19321923
pub fn length_hint(&self, iter: PyObjectRef) -> PyResult<Option<usize>> {
19331924
if let Some(len) = self.obj_len_opt(&iter) {
19341925
match len {

0 commit comments

Comments
 (0)