diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index ad5d4076d..606fa1be6 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -3351,8 +3351,6 @@ class ProtocolTests(BaseTestCase): self.assertNotIsSubclass(C, Protocol) self.assertNotIsInstance(C(), Protocol) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_protocols_issubclass_non_callable(self): class C: x = 1 @@ -3412,8 +3410,6 @@ class ProtocolTests(BaseTestCase): ): issubclass(Eggs, Spam) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_no_weird_caching_with_issubclass_after_isinstance_2(self): @runtime_checkable class Spam(Protocol): @@ -3434,8 +3430,6 @@ class ProtocolTests(BaseTestCase): ): issubclass(Eggs, Spam) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_no_weird_caching_with_issubclass_after_isinstance_3(self): @runtime_checkable class Spam(Protocol): diff --git a/vm/src/stdlib/typing.rs b/vm/src/stdlib/typing.rs index 9f0764e81..5bbae8ae9 100644 --- a/vm/src/stdlib/typing.rs +++ b/vm/src/stdlib/typing.rs @@ -48,7 +48,10 @@ pub(crate) mod decl { #[pyfunction(name = "override")] pub(crate) fn r#override(func: PyObjectRef, vm: &VirtualMachine) -> PyResult { // Set __override__ attribute to True - func.set_attr("__override__", vm.ctx.true_value.clone(), vm)?; + // Skip the attribute silently if it is not writable. + // AttributeError happens if the object has __slots__ or a + // read-only property, TypeError if it's a builtin class. + let _ = func.set_attr("__override__", vm.ctx.true_value.clone(), vm); Ok(func) }