From a911de81b2c9190b78ea89c12675a8b694a3f879 Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Wed, 17 Jun 2026 10:34:44 +0300 Subject: [PATCH 1/3] Align patches at `test_types.py` --- Lib/test/test_types.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index 01da70b4c68..c172eb714ed 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -45,7 +45,6 @@ def clear_typing_caches(): class TypesTests(unittest.TestCase): - @unittest.skipUnless(c_types, "TODO: RUSTPYTHON; requires _types module") def test_names(self): c_only_names = {'CapsuleType'} ignored = {'new_class', 'resolve_bases', 'prepare_class', @@ -636,7 +635,7 @@ def test_slot_wrapper_types(self): self.assertIsInstance(object.__lt__, types.WrapperDescriptorType) self.assertIsInstance(int.__lt__, types.WrapperDescriptorType) - @unittest.expectedFailure # TODO: RUSTPYTHON; No signature found in builtin method __get__ of 'method_descriptor' objects. + @unittest.expectedFailure # TODO: RUSTPYTHON; ValueError: no signature found for builtin Date: Wed, 17 Jun 2026 12:03:29 +0300 Subject: [PATCH 2/3] Add missing methods for `_io.TextIOBase` --- Lib/test/test_types.py | 2 +- crates/vm/src/stdlib/_io.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index c172eb714ed..63bc0803e79 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -660,7 +660,7 @@ def test_method_descriptor_types(self): self.assertIsInstance(int.from_bytes, types.BuiltinMethodType) self.assertIsInstance(int.__new__, types.BuiltinMethodType) - @unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: type object '_io._TextIOBase' has no attribute 'read' + @unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: descriptor 'read' needs a type, not 'StringIO', as arg 2 def test_method_descriptor_crash(self): # gh-132747: The default __get__() implementation in C was unable # to handle a second argument of None when called from Python diff --git a/crates/vm/src/stdlib/_io.rs b/crates/vm/src/stdlib/_io.rs index 423d5bc676f..dd01c46fda5 100644 --- a/crates/vm/src/stdlib/_io.rs +++ b/crates/vm/src/stdlib/_io.rs @@ -789,11 +789,41 @@ mod _io { #[pyclass(flags(BASETYPE, HAS_WEAKREF))] impl _TextIOBase { + #[pymethod] + fn read(zelf: PyObjectRef, _size: OptionalArg, vm: &VirtualMachine) -> PyResult { + _unsupported(vm, &zelf, "read") + } + + #[pymethod] + fn write(zelf: PyObjectRef, _b: PyObjectRef, vm: &VirtualMachine) -> PyResult { + _unsupported(vm, &zelf, "write") + } + + #[pymethod] + fn truncate(zelf: PyObjectRef, _pos: OptionalArg, vm: &VirtualMachine) -> PyResult { + _unsupported(vm, &zelf, "truncate") + } + + #[pymethod] + fn readline(zelf: PyObjectRef, vm: &VirtualMachine) -> PyResult { + _unsupported(vm, &zelf, "readline") + } + + #[pymethod] + fn detach(zelf: PyObjectRef, vm: &VirtualMachine) -> PyResult { + _unsupported(vm, &zelf, "detach") + } + #[pygetset] fn encoding(_zelf: PyObjectRef, vm: &VirtualMachine) -> PyObjectRef { vm.ctx.none() } + #[pygetset] + fn newlines(_zelf: PyObjectRef, vm: &VirtualMachine) -> PyObjectRef { + vm.ctx.none() + } + #[pygetset] fn errors(_zelf: PyObjectRef, vm: &VirtualMachine) -> PyObjectRef { vm.ctx.none() From 67f7ff81ad9fdc669e91f767c47588e5bfe9bc1d Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Wed, 17 Jun 2026 13:03:04 +0300 Subject: [PATCH 3/3] Unmark passing test --- Lib/test/test_memoryio.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py index 7214a377067..0ae48600529 100644 --- a/Lib/test/test_memoryio.py +++ b/Lib/test/test_memoryio.py @@ -1026,10 +1026,6 @@ def test_relative_seek(self): def test_flags(self): return super().test_flags() - @unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: 'StringIO' object has no attribute 'detach' - def test_detach(self): - return super().test_detach() - @unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: 'StringIO' object has no attribute 'newlines'. Did you mean: 'readlines'? def test_newlines_property(self): return super().test_newlines_property()