diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2006-08-09 07:57:39 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2006-08-09 07:57:39 (GMT) |
commit | ab2f8f7bd556c16a2b30aa8ec05d4c9d8c50d311 (patch) | |
tree | 173d0b8612bd7a76a7fc9c8105e8a53370dbd7ab /Lib | |
parent | 209307eb3bca9aeb9b842014edcfe8df9cbb7f91 (diff) | |
download | cpython-ab2f8f7bd556c16a2b30aa8ec05d4c9d8c50d311.zip cpython-ab2f8f7bd556c16a2b30aa8ec05d4c9d8c50d311.tar.gz cpython-ab2f8f7bd556c16a2b30aa8ec05d4c9d8c50d311.tar.bz2 |
__hash__ may now return long int; the final hash
value is obtained by invoking hash on the long int.
Fixes #1536021.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_builtin.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 70480be..26bfe87 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -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') |