File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1184,6 +1184,16 @@ def __hash__(self):
11841184 return self
11851185 self .assertEqual (hash (Z (42 )), hash (42 ))
11861186
1187+ def test_invalid_hash_typeerror (self ):
1188+ # GH-140406: The returned object from __hash__() would leak if it
1189+ # wasn't an integer.
1190+ class A :
1191+ def __hash__ (self ):
1192+ return 1.0
1193+
1194+ with self .assertRaises (TypeError ):
1195+ hash (A ())
1196+
11871197 def test_hex (self ):
11881198 self .assertEqual (hex (16 ), '0x10' )
11891199 self .assertEqual (hex (- 16 ), '-0x10' )
Original file line number Diff line number Diff line change @@ -166,16 +166,6 @@ def test_hashes(self):
166166 for obj in self .hashes_to_check :
167167 self .assertEqual (hash (obj ), _default_hash (obj ))
168168
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- with self .assertRaises (TypeError ):
177- hash (A ())
178-
179169class HashRandomizationTests :
180170
181171 # Each subclass should define a field "repr_", containing the repr() of
You can’t perform that action at this time.
0 commit comments