Hello! I think it's a strange behavior: Python 3.1a0 (py3k:67851, Dec 19 2008, 16:50:32) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
hash(range(10)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'range' dir(range(10)) ['__class__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__'] hash(range(10)) -1211318616 hash(range(1000)) -1211318472
-- Dmitry Vasiliev (dima at hlabs.spb.ru) http://hlabs.spb.ru
Dmitry Vasiliev schrieb:
Hello!
I think it's a strange behavior:
Python 3.1a0 (py3k:67851, Dec 19 2008, 16:50:32) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
hash(range(10)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'range' dir(range(10)) ['__class__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__'] hash(range(10)) -1211318616 hash(range(1000)) -1211318472
Yes, it is. I'm able to reproduce the problem. Christian
Christian Heimes wrote:
Dmitry Vasiliev schrieb:
Hello!
I think it's a strange behavior:
Python 3.1a0 (py3k:67851, Dec 19 2008, 16:50:32) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
hash(range(10)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'range' dir(range(10)) ['__class__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__'] hash(range(10)) -1211318616 hash(range(1000)) -1211318472
Yes, it is. I'm able to reproduce the problem.
It's not just dir(). Same behavior with help(): Python 3.1a0 (py3k:67856, Dec 19 2008, 10:18:03) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information.
hash(range(10)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'range' [43173 refs] help(range(10))
[77213 refs]
hash(range(10)) 5041912 [77215 refs]
On Fri, Dec 19, 2008 at 12:20 PM, Dmitry Vasiliev
Hello!
I think it's a strange behavior:
Python 3.1a0 (py3k:67851, Dec 19 2008, 16:50:32) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
hash(range(10)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'range' dir(range(10)) ['__class__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__'] hash(range(10)) -1211318616 hash(range(1000)) -1211318472
There are other ways to reproduce it without using dir, like range(10).__class__; hash(range(10)) Is there some reason no set tp_hash for rangeobject to PyObject_HashNotImplemented ?
-- Dmitry Vasiliev (dima at hlabs.spb.ru) http://hlabs.spb.ru
-- -- Guilherme H. Polo Goncalves
Is there some reason no set tp_hash for rangeobject to PyObject_HashNotImplemented ?
http://bugs.python.org/issue4701 - Hagen
participants (5)
-
Christian Heimes
-
Dmitry Vasiliev
-
Eric Smith
-
Guilherme Polo
-
Hagen Fürstenau