Commit ca9d59b7 authored by Marius Wachtler's avatar Marius Wachtler

long.__hash__ has to return same hash as an int if the value fits inside an int

parent 0b954e79
......@@ -1241,6 +1241,10 @@ Box* longHash(BoxedLong* self) {
raiseExcHelper(TypeError, "descriptor '__pow__' requires a 'long' object but received a '%s'",
getTypeName(self));
// If the long fits into an int we have to return the same hash in order that we can find the value in a dict.
if (mpz_fits_slong_p(self->n))
return boxInt(mpz_get_si(self->n));
// Not sure if this is a good hash function or not;
// simple, but only includes top bits:
union {
......
d = {2:2}
d[1] = 1
print d
print d[1]
print d[1], d[1L], d[1.0], d[True]
d = {}
for i in xrange(10):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment