From 57ea33560662e0f20a3b0334bb20065771edf4da Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Tue, 10 Sep 2019 13:21:57 +0200 Subject: bpo-37619: update_one_slot() should not ignore wrapper descriptors for wrong type (GH-14836) --- Lib/test/test_descr.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Lib/test/test_descr.py') diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 4368bb585f..796e60a770 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -4649,6 +4649,18 @@ order (MRO) for bases """ 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: -- cgit v1.2.1