Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix io
  • Loading branch information
youknowone committed Feb 5, 2026
commit 258ac74384527176cbf8d6c79307a91b2154b1b6
2 changes: 2 additions & 0 deletions Lib/test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4071,6 +4071,8 @@ def __setstate__(slf, state):
self.assertEqual(newtxt.tag, 'ham')
del MyTextIO

# TODO: RUSTPYTHON; TypeError: a bytes-like object is required, not 'NoneType'
@unittest.expectedFailure
@unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()")
def test_read_non_blocking(self):
import os
Expand Down
11 changes: 7 additions & 4 deletions crates/vm/src/stdlib/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,12 @@ mod _io {

impl Destructor for _IOBase {
fn slot_del(zelf: &PyObject, vm: &VirtualMachine) -> PyResult<()> {
iobase_finalize(zelf, vm);
// C-level IO types (FileIO, Buffered*, TextIOWrapper) have their own
// slot_del that calls iobase_finalize with proper _finalizing flag
// and _dealloc_warn chain. This base fallback is only reached by
// Python-level subclasses, where we silently discard close() errors
// to avoid surfacing unraisables from partially initialized objects.
let _ = vm.call_method(zelf, "close", ());
Ok(())
}

Expand Down Expand Up @@ -4591,10 +4596,8 @@ mod _io {
}

#[pymethod]
fn close(&self, vm: &VirtualMachine) -> PyResult<()> {
drop(self.try_resizable(vm)?);
fn close(&self) {
self.closed.store(true);
Ok(())
}

#[pymethod]
Expand Down