Repository: RustPython/RustPython (language: rust)

Issue:
Mismatching abstractmethod error messages
Python 3.12 changed error messages.

https://github.com/RustPython/RustPython/pull/5134/files#diff-e020d5ddd536ec48b0414753af7d5240750a05262f32dad378b4c79e6cc3743dR152-R160 (#5134)

Related source code in RustPython is in `vm/src/builtins/object.rs`.



Discussion / hints:
@NakanoMiku39 Are you interested in this issue?
> itle ~Fix abstractmethod error messages~ Mismatching abstractmethod

Yeah Sure

Fix patch:
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<PyStrRef> = 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
                         )));
                     }


Test patch:
diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py
index d912954a41..ac46ea67bb 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
@@ -159,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
@@ -526,8 +522,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 +538,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 +589,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 +608,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/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