@@ -20,8 +20,7 @@ use crate::obj::objbytes;
2020use crate :: obj:: objint;
2121use crate :: obj:: objstr;
2222use crate :: pyobject:: {
23- AttributeProtocol , BufferProtocol , PyContext , PyObject , PyObjectRef , PyRef , PyResult , PyValue ,
24- TypeProtocol ,
23+ BufferProtocol , PyContext , PyObject , PyObjectRef , PyRef , PyResult , PyValue , TypeProtocol ,
2524} ;
2625use crate :: vm:: VirtualMachine ;
2726
@@ -165,7 +164,7 @@ fn file_io_init(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
165164
166165fn file_io_read ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
167166 arg_check ! ( vm, args, required = [ ( file_io, None ) ] ) ;
168- let py_name = file_io. get_attr ( "name" ) . unwrap ( ) ;
167+ let py_name = vm . get_attribute ( file_io. clone ( ) , "name" ) ? ;
169168 let f = match File :: open ( objstr:: get_value ( & py_name) ) {
170169 Ok ( v) => Ok ( v) ,
171170 Err ( _) => Err ( vm. new_type_error ( "Error opening file" . to_string ( ) ) ) ,
@@ -200,7 +199,7 @@ fn file_io_readinto(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
200199 let py_length = vm. call_method ( obj, "__len__" , PyFuncArgs :: default ( ) ) ?;
201200 let length = objint:: get_value ( & py_length) . to_u64 ( ) . unwrap ( ) ;
202201
203- let file_no = file_io. get_attr ( "fileno" ) . unwrap ( ) ;
202+ let file_no = vm . get_attribute ( file_io. clone ( ) , "fileno" ) ? ;
204203 let raw_fd = objint:: get_value ( & file_no) . to_i64 ( ) . unwrap ( ) ;
205204
206205 //extract unix file descriptor.
@@ -230,7 +229,7 @@ fn file_io_write(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
230229 required = [ ( file_io, None ) , ( obj, Some ( vm. ctx. bytes_type( ) ) ) ]
231230 ) ;
232231
233- let file_no = file_io. get_attr ( "fileno" ) . unwrap ( ) ;
232+ let file_no = vm . get_attribute ( file_io. clone ( ) , "fileno" ) ? ;
234233 let raw_fd = objint:: get_value ( & file_no) . to_i64 ( ) . unwrap ( ) ;
235234
236235 //unsafe block - creates file handle from the UNIX file descriptor
0 commit comments