You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The difference in these values is 2^32. From the python documentation, if __hash__ returns a long, then that long may be further hashed to produce a 32 bit integer which appears to be what is happening here, where id() is returning longs on 32 bit archs but not on 64 bit archs.
Overall, this test appears to be testing the internals of the interpreter and not turning the hashing on/off as desired. Would a better test be to check that a TypeError is not raised?
64 bit Python
(sid_amd64-dchroot)$ python
Python 2.7.12+ (default, Nov 4 2016, 17:04:30)
[GCC 6.2.0 20161027] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo():
... def __hash__(self):
... return id(self)
...
>>> f = Foo()
>>> id(f)
140149834025872
>>> hash(f)
140149834025872
>>>
32 bit Python
(sid_i386-dchroot)$ python
Python 2.7.12+ (default, Nov 4 2016, 17:04:30)
[GCC 6.2.0 20161027] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo():
... def __hash__(self):
... return id(self)
...
>>> f = Foo()
>>> id(f)
4143861580L
>>> hash(f)
-151105716
>>>
The text was updated successfully, but these errors were encountered:
Hi!
When executing the test suite on 32 bit architectures (Debian's i386 and armhf), the test suite fails with an architecture specific error:
The difference in these values is 2^32. From the python documentation, if
__hash__
returns a long, then that long may be further hashed to produce a 32 bit integer which appears to be what is happening here, whereid()
is returning longs on 32 bit archs but not on 64 bit archs.https://docs.python.org/2/reference/datamodel.html#object.__hash__
Overall, this test appears to be testing the internals of the interpreter and not turning the hashing on/off as desired. Would a better test be to check that a
TypeError
is not raised?64 bit Python
32 bit Python
The text was updated successfully, but these errors were encountered: