diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-06-29 23:58:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-29 23:58:45 +0100 |
commit | e2fea101fd5517f33371b04432842b971021c3bf (patch) | |
tree | 377326d96ccca7fe54787dae19dac6df8a928308 /Lib/test/test_weakref.py | |
parent | 12803c59d54ff1a45a5b08cef82652ef199b3b07 (diff) | |
download | cpython-e2fea101fd5517f33371b04432842b971021c3bf.tar.gz cpython-e2fea101fd5517f33371b04432842b971021c3bf.zip |
bpo-44523: Remove the pass-through for hash() in weakref proxy objects (GH-26950)
Diffstat (limited to 'Lib/test/test_weakref.py')
-rw-r--r-- | Lib/test/test_weakref.py | 14 |
1 files changed, 10 insertions, 4 deletions
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() |