File tree Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -151,7 +151,12 @@ impl PyObjectRef {
151
151
// int PyObject_TypeCheck(PyObject *o, PyTypeObject *type)
152
152
153
153
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
+ } )
155
160
}
156
161
157
162
pub fn length_hint (
Original file line number Diff line number Diff line change @@ -1920,15 +1920,6 @@ impl VirtualMachine {
1920
1920
} )
1921
1921
}
1922
1922
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
-
1932
1923
pub fn length_hint ( & self , iter : PyObjectRef ) -> PyResult < Option < usize > > {
1933
1924
if let Some ( len) = self . obj_len_opt ( & iter) {
1934
1925
match len {
You can’t perform that action at this time.
0 commit comments