bpo-37619: update_one_slot() should not ignore wrapper descriptors for wrong type (GH-14836)
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 4368bb5..796e60a 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -4649,6 +4649,18 @@
self.assertEqual(x["y"], 42)
self.assertEqual(x, -x)
+ def test_wrong_class_slot_wrapper(self):
+ # Check bpo-37619: a wrapper descriptor taken from the wrong class
+ # should raise an exception instead of silently being ignored
+ class A(int):
+ __eq__ = str.__eq__
+ __add__ = str.__add__
+ a = A()
+ with self.assertRaises(TypeError):
+ a == a
+ with self.assertRaises(TypeError):
+ a + a
+
def test_slot_shadows_class_variable(self):
with self.assertRaises(ValueError) as cm:
class X: