mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
__hash__ may now return long int; the final hash
value is obtained by invoking hash on the long int. Fixes #1536021.
This commit is contained in:
parent
209307eb3b
commit
ab2f8f7bd5
5 changed files with 24 additions and 6 deletions
|
|
@ -640,6 +640,15 @@ class BuiltinTest(unittest.TestCase):
|
|||
def f(): pass
|
||||
self.assertRaises(TypeError, hash, [])
|
||||
self.assertRaises(TypeError, hash, {})
|
||||
# Bug 1536021: Allow hash to return long objects
|
||||
class X:
|
||||
def __hash__(self):
|
||||
return 2**100
|
||||
self.assertEquals(type(hash(X())), int)
|
||||
class Y(object):
|
||||
def __hash__(self):
|
||||
return 2**100
|
||||
self.assertEquals(type(hash(Y())), int)
|
||||
|
||||
def test_hex(self):
|
||||
self.assertEqual(hex(16), '0x10')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue