From e2fea101fd5517f33371b04432842b971021c3bf Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Tue, 29 Jun 2021 23:58:45 +0100 Subject: bpo-44523: Remove the pass-through for hash() in weakref proxy objects (GH-26950) --- Lib/test/test_weakref.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'Lib/test/test_weakref.py') diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py index 56a42f055d0..dd5a781ed59 100644 --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -422,14 +422,20 @@ class ReferencesTestCase(TestBase): self.assertEqual("".join(reversed(weakref.proxy(obj))), "cba") def test_proxy_hash(self): - cool_hash = 299_792_458 - class MyObj: def __hash__(self): - return cool_hash + return 42 + + obj = MyObj() + with self.assertRaises(TypeError): + hash(weakref.proxy(obj)) + + class MyObj: + __hash__ = None obj = MyObj() - self.assertEqual(hash(weakref.proxy(obj)), cool_hash) + with self.assertRaises(TypeError): + hash(weakref.proxy(obj)) def test_getweakrefcount(self): o = C() -- cgit v1.2.3