Skip to content

Commit 278e1a8

Browse files
committed
method name change for fileio
1 parent 08a9fd9 commit 278e1a8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

vm/src/stdlib/io.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn file_io_read_into(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
8989
arg_check!(
9090
vm,
9191
args,
92-
required = [(file_io, None), (view, Some(vm.ctx.bytes_type()))]
92+
required = [(file_io, None), (view, Some(vm.ctx.bytearray_type()))]
9393
);
9494
let py_name = file_io.get_attr("name").unwrap();
9595
let f = match File::open(get_value(& py_name)) {
@@ -117,6 +117,8 @@ fn file_io_read_into(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
117117

118118
fn buffered_reader_read(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
119119
arg_check!(vm, args);
120+
121+
//simple calls read on the read class!
120122
// TODO
121123
Ok(vm.get_none())
122124
}
@@ -130,6 +132,7 @@ fn io_open(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
130132

131133

132134
Ok(vm.get_none())
135+
133136
//mode is optional: 'rt' is the default mode (open from reading text)
134137
//To start we construct a FileIO (subclass of RawIOBase)
135138
//This is subsequently consumed by a Buffered_class of type depending
@@ -139,6 +142,7 @@ fn io_open(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
139142
// reading => BufferedReader
140143
// If the mode is binary this Buffered class is returned directly at
141144
// this point.
145+
//For Buffered class construct "raw" IO class e.g. FileIO and pass this into corresponding field
142146

143147
//If the mode is text this buffer type is consumed on construction of
144148
//a TextIOWrapper which is subsequently returned.
@@ -168,7 +172,7 @@ pub fn mk_module(ctx: &PyContext) -> PyObjectRef {
168172
ctx.set_attr(&file_io, "__init__", ctx.new_rustfunc(file_io_init));
169173
ctx.set_attr(&file_io, "name", ctx.str_type());
170174
ctx.set_attr(&file_io, "read", ctx.new_rustfunc(file_io_read));
171-
ctx.set_attr(&file_io, "read_into", ctx.new_rustfunc(file_io_read_into));
175+
ctx.set_attr(&file_io, "readinto", ctx.new_rustfunc(file_io_read_into));
172176
ctx.set_attr(&py_mod, "FileIO", file_io.clone());
173177

174178
// BufferedIOBase Subclasses

0 commit comments

Comments
 (0)