From 32e693f2345accd5fb89b47f9af3487e07cab786 Mon Sep 17 00:00:00 2001 From: ChJR Date: Wed, 20 Oct 2021 02:33:46 +0900 Subject: [PATCH] Replace vm.obj_len to obj.length --- vm/src/protocol/object.rs | 7 ++++++- vm/src/vm.rs | 9 --------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/vm/src/protocol/object.rs b/vm/src/protocol/object.rs index 940512d0ef..b2e989076e 100644 --- a/vm/src/protocol/object.rs +++ b/vm/src/protocol/object.rs @@ -151,7 +151,12 @@ impl PyObjectRef { // int PyObject_TypeCheck(PyObject *o, PyTypeObject *type) pub fn length(&self, vm: &VirtualMachine) -> PyResult { - 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( diff --git a/vm/src/vm.rs b/vm/src/vm.rs index bb60bd7e04..3b97bfc805 100644 --- a/vm/src/vm.rs +++ b/vm/src/vm.rs @@ -1920,15 +1920,6 @@ impl VirtualMachine { }) } - pub fn obj_len(&self, obj: &PyObjectRef) -> PyResult { - 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> { if let Some(len) = self.obj_len_opt(&iter) { match len {