Author: Kunal Grover <[email protected]>
Branch: py3.3-hashfix
Changeset: r83698:da3b47de3e90
Date: 2016-02-19 01:23 +0530
http://bitbucket.org/pypy/pypy/changeset/da3b47de3e90/
Log: Raise NotImplemented when value not an integer or float in
specialisedtuple
diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -520,21 +520,7 @@
return _new_int(space, w_inttype, w_x, w_base)
def descr_hash(self, space):
- a = self.intval
- sign = 1
- if a < 0:
- sign = -1
- a = -a
-
- x = r_uint(a)
- # efficient x % HASH_MODULUS: as HASH_MODULUS is a Mersenne
- # prime
- x = (x & HASH_MODULUS) + (x >> HASH_BITS)
- if x >= HASH_MODULUS:
- x -= HASH_MODULUS
-
- x = intmask(intmask(x) * sign)
- return wrapint(space, -2 if x == -1 else x)
+ return space.wrap(_hash_int(space, self.intval))
def as_w_long(self, space):
# XXX: should try smalllong
diff --git a/pypy/objspace/std/specialisedtupleobject.py
b/pypy/objspace/std/specialisedtupleobject.py
--- a/pypy/objspace/std/specialisedtupleobject.py
+++ b/pypy/objspace/std/specialisedtupleobject.py
@@ -1,7 +1,7 @@
from pypy.interpreter.error import OperationError
from pypy.objspace.std.tupleobject import W_AbstractTupleObject
from pypy.objspace.std.util import negate
-from rpython.rlib.objectmodel import compute_hash, specialize
+from rpython.rlib.objectmodel import specialize
from rpython.rlib.rarithmetic import intmask
from rpython.rlib.unroll import unrolling_iterable
from rpython.tool.sourcetools import func_with_new_name
@@ -73,7 +73,8 @@
from pypy.objspace.std.intobject import _hash_int
y = _hash_int(space, value)
else:
- y = compute_hash(value)
+ raise NotImplementedError
+
x = (x ^ y) * mult
z -= 1
mult += 82520 + z + z
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit