Skip to content

Commit aea929a

Browse files
Merge pull request RustPython#319 from holygits/fix-fileno
Revert 'file_no' -> 'fileno' attr naming
2 parents f4a78d4 + 5cad1b0 commit aea929a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

vm/src/stdlib/io.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn file_io_init(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
116116
let file_no = os::os_open(vm, PyFuncArgs::new(args, vec![]))?;
117117

118118
vm.ctx.set_attr(&file_io, "name", name.clone());
119-
vm.ctx.set_attr(&file_io, "file_no", file_no);
119+
vm.ctx.set_attr(&file_io, "fileno", file_no);
120120
Ok(vm.get_none())
121121
}
122122
None => Err(vm.new_type_error(format!("invalid mode {}", rust_mode))),
@@ -161,7 +161,7 @@ fn file_io_readinto(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
161161
let py_length = vm.invoke(len_method.unwrap(), PyFuncArgs::default());
162162
let length = objint::get_value(&py_length.unwrap()).to_u64().unwrap();
163163

164-
let file_no = file_io.get_attr("file_no").unwrap();
164+
let file_no = file_io.get_attr("fileno").unwrap();
165165
let raw_fd = objint::get_value(&file_no).to_i32().unwrap();
166166

167167
//unsafe block - creates file handle from the UNIX file descriptor
@@ -184,7 +184,7 @@ fn file_io_readinto(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
184184

185185
let new_handle = f.into_inner().into_raw_fd().to_bigint();
186186
vm.ctx
187-
.set_attr(&file_io, "file_no", vm.ctx.new_int(new_handle.unwrap()));
187+
.set_attr(&file_io, "fileno", vm.ctx.new_int(new_handle.unwrap()));
188188
Ok(vm.get_none())
189189
}
190190

@@ -195,7 +195,7 @@ fn file_io_write(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
195195
required = [(file_io, None), (obj, Some(vm.ctx.bytes_type()))]
196196
);
197197

198-
let file_no = file_io.get_attr("file_no").unwrap();
198+
let file_no = file_io.get_attr("fileno").unwrap();
199199
let raw_fd = objint::get_value(&file_no).to_i32().unwrap();
200200

201201
//unsafe block - creates file handle from the UNIX file descriptor
@@ -210,7 +210,7 @@ fn file_io_write(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
210210
//reset raw fd on the FileIO object
211211
let new_handle = handle.into_raw_fd().to_bigint();
212212
vm.ctx
213-
.set_attr(&file_io, "file_no", vm.ctx.new_int(new_handle.unwrap()));
213+
.set_attr(&file_io, "fileno", vm.ctx.new_int(new_handle.unwrap()));
214214

215215
//return number of bytes written
216216
Ok(vm.ctx.new_int(len.to_bigint().unwrap()))

0 commit comments

Comments
 (0)