Skip to content

Commit 0b9964c

Browse files
committed
fix io
1 parent 77bed9a commit 0b9964c

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Lib/test/test_io.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4071,6 +4071,8 @@ def __setstate__(slf, state):
40714071
self.assertEqual(newtxt.tag, 'ham')
40724072
del MyTextIO
40734073

4074+
# TODO: RUSTPYTHON; TypeError: a bytes-like object is required, not 'NoneType'
4075+
@unittest.expectedFailure
40744076
@unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()")
40754077
def test_read_non_blocking(self):
40764078
import os

crates/vm/src/stdlib/io.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,12 @@ mod _io {
639639

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

@@ -4591,10 +4596,8 @@ mod _io {
45914596
}
45924597

45934598
#[pymethod]
4594-
fn close(&self, vm: &VirtualMachine) -> PyResult<()> {
4595-
drop(self.try_resizable(vm)?);
4599+
fn close(&self) {
45964600
self.closed.store(true);
4597-
Ok(())
45984601
}
45994602

46004603
#[pymethod]

0 commit comments

Comments
 (0)