We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b1013fe commit ed017f0Copy full SHA for ed017f0
Lib/test/test_hash.py
@@ -166,6 +166,17 @@ def test_hashes(self):
166
for obj in self.hashes_to_check:
167
self.assertEqual(hash(obj), _default_hash(obj))
168
169
+ def test_invalid_hash_typeerror(self):
170
+ # GH-140406: The returned object from __hash__() would leak if it
171
+ # wasn't an integer.
172
+ class A:
173
+ def __hash__(self):
174
+ return 1.0
175
+
176
+ for _ in range(100):
177
+ with self.assertRaises(TypeError):
178
+ hash(A())
179
180
class HashRandomizationTests:
181
182
# Each subclass should define a field "repr_", containing the repr() of
0 commit comments