From 3bce41baabb61ebdfcaf40d046b80c24af50735e Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" <69878+youknowone@users.noreply.github.com> Date: Mon, 21 Jul 2025 00:54:14 +0900 Subject: [PATCH] Fix test_typing.test_unpack_wrong_type (#6009) --- Lib/test/test_descr.py | 2 -- Lib/test/test_typing.py | 2 -- vm/src/types/slot.rs | 5 ++++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 7698c340c..6f1849738 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -5074,8 +5074,6 @@ order (MRO) for bases """ gc.collect() self.assertEqual(Parent.__subclasses__(), []) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_attr_raise_through_property(self): # test case for gh-103272 class A: diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 229d61ad1..5241038a2 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -1228,8 +1228,6 @@ class UnpackTests(BaseTestCase): self.assertEqual(PartNew[Unpack[tuple[str]]].__args__, (int, str)) self.assertEqual(PartNew[Unpack[Tuple[str]]].__args__, (int, str)) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_unpack_wrong_type(self): Ts = TypeVarTuple("Ts") class Gen[*Ts]: ... diff --git a/vm/src/types/slot.rs b/vm/src/types/slot.rs index 35a387ed7..8788b9f3a 100644 --- a/vm/src/types/slot.rs +++ b/vm/src/types/slot.rs @@ -286,7 +286,10 @@ fn getattro_wrapper(zelf: &PyObject, name: &Py, vm: &VirtualMachine) -> P let __getattr__ = identifier!(vm, __getattr__); match vm.call_special_method(zelf, __getattribute__, (name.to_owned(),)) { Ok(r) => Ok(r), - Err(_) if zelf.class().has_attr(__getattr__) => { + Err(e) + if e.fast_isinstance(vm.ctx.exceptions.attribute_error) + && zelf.class().has_attr(__getattr__) => + { vm.call_special_method(zelf, __getattr__, (name.to_owned(),)) } Err(e) => Err(e),