From 7e91b98837426de6abcd46ab9f5b978c4db13748 Mon Sep 17 00:00:00 2001 From: NakanoMiku Date: Thu, 28 Dec 2023 12:42:39 +0800 Subject: [PATCH 1/3] Update vm/src/builtins/object.rs Fix error messages --- Lib/test/test_abc.py | 12 +----------- vm/src/builtins/object.rs | 6 +++--- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py index d912954a41..e90b5c363d 100644 --- a/Lib/test/test_abc.py +++ b/Lib/test/test_abc.py @@ -149,8 +149,6 @@ def foo(): return 4 self.assertEqual(D.foo(), 4) self.assertEqual(D().foo(), 4) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_object_new_with_one_abstractmethod(self): class C(metaclass=abc_ABCMeta): @abc.abstractmethod @@ -160,7 +158,7 @@ def method_one(self): self.assertRaisesRegex(TypeError, msg, C) # TODO: RUSTPYTHON - @unittest.expectedFailure + ##@unittest.expectedFailure def test_object_new_with_many_abstractmethods(self): class C(metaclass=abc_ABCMeta): @abc.abstractmethod @@ -526,8 +524,6 @@ def foo(self): self.assertEqual(A.__abstractmethods__, set()) A() - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_update_new_abstractmethods(self): class A(metaclass=abc_ABCMeta): @abc.abstractmethod @@ -544,8 +540,6 @@ def updated_foo(self): msg = "class A without an implementation for abstract methods 'bar', 'foo'" self.assertRaisesRegex(TypeError, msg, A) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_update_implementation(self): class A(metaclass=abc_ABCMeta): @abc.abstractmethod @@ -597,8 +591,6 @@ def updated_foo(self): A() self.assertFalse(hasattr(A, '__abstractmethods__')) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_update_del_implementation(self): class A(metaclass=abc_ABCMeta): @abc.abstractmethod @@ -618,8 +610,6 @@ def foo(self): msg = "class B without an implementation for abstract method 'foo'" self.assertRaisesRegex(TypeError, msg, B) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_update_layered_implementation(self): class A(metaclass=abc_ABCMeta): @abc.abstractmethod diff --git a/vm/src/builtins/object.rs b/vm/src/builtins/object.rs index efe6aa980f..3b3d1ab365 100644 --- a/vm/src/builtins/object.rs +++ b/vm/src/builtins/object.rs @@ -41,7 +41,7 @@ impl Constructor for PyBaseObject { if let Some(unimplemented_abstract_method_count) = abs_methods.length_opt(vm) { let methods: Vec = abs_methods.try_to_value(vm)?; let methods: String = - Itertools::intersperse(methods.iter().map(|name| name.as_str()), ", ") + Itertools::intersperse(methods.iter().map(|name| name.as_str()), "', '") .collect(); let unimplemented_abstract_method_count = unimplemented_abstract_method_count?; @@ -51,13 +51,13 @@ impl Constructor for PyBaseObject { 0 => {} 1 => { return Err(vm.new_type_error(format!( - "Can't instantiate abstract class {} with abstract method {}", + "class {} without an implementation for abstract method '{}'", name, methods ))); } 2.. => { return Err(vm.new_type_error(format!( - "Can't instantiate abstract class {} with abstract methods {}", + "class {} without an implementation for abstract methods '{}'", name, methods ))); } From 0dac5e162bcbd7fb520efda729efb1b83bdffdd9 Mon Sep 17 00:00:00 2001 From: NakanoMiku Date: Thu, 28 Dec 2023 12:50:13 +0800 Subject: [PATCH 2/3] Update test_abc.py --- Lib/test/test_abc.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py index e90b5c363d..ac46ea67bb 100644 --- a/Lib/test/test_abc.py +++ b/Lib/test/test_abc.py @@ -157,8 +157,6 @@ def method_one(self): msg = r"class C without an implementation for abstract method 'method_one'" self.assertRaisesRegex(TypeError, msg, C) - # TODO: RUSTPYTHON - ##@unittest.expectedFailure def test_object_new_with_many_abstractmethods(self): class C(metaclass=abc_ABCMeta): @abc.abstractmethod From c2e64aba285d3698cb805d283789d19cbe31b170 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Thu, 11 Jan 2024 16:21:29 +0900 Subject: [PATCH 3/3] mark test_dataclasses.test_maintain_abc expectedFailure --- Lib/test/test_dataclasses.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 33bd9d0cb6..2e51e43ae8 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -3676,6 +3676,7 @@ class Date(Ordered): self.assertFalse(inspect.isabstract(Date)) self.assertGreater(Date(2020,12,25), Date(2020,8,31)) + @unittest.expectedFailure def test_maintain_abc(self): class A(abc.ABC): @abc.abstractmethod