Author: Michal Bendowski <[email protected]>
Branch: jvm-improvements
Changeset: r51382:259f2ab80ae4
Date: 2012-01-16 22:26 +0100
http://bitbucket.org/pypy/pypy/changeset/259f2ab80ae4/
Log: Fix the implementation of compute_unique_id for _builtin_type.
diff --git a/pypy/rpython/ootypesystem/ootype.py
b/pypy/rpython/ootypesystem/ootype.py
--- a/pypy/rpython/ootypesystem/ootype.py
+++ b/pypy/rpython/ootypesystem/ootype.py
@@ -1378,7 +1378,7 @@
return make_object(self)
def _identityhash(self):
- return hash(self)
+ return object.__hash__(self)
class _string(_builtin_type):
diff --git a/pypy/rpython/test/test_rbuiltin.py
b/pypy/rpython/test/test_rbuiltin.py
--- a/pypy/rpython/test/test_rbuiltin.py
+++ b/pypy/rpython/test/test_rbuiltin.py
@@ -477,6 +477,17 @@
for id in self.ll_unpack_tuple(res, 6):
assert isinstance(id, (int, r_longlong))
+ def test_uniqueness_of_id_on_strings(self):
+ from pypy.rlib.objectmodel import compute_unique_id
+ def fn(s1, s2):
+ return (compute_unique_id(s1), compute_unique_id(s2))
+
+ s1 = "foo"
+ s2 = ''.join(['f','oo'])
+ res = self.interpret(fn, [self.string_to_ll(s1),
self.string_to_ll(s2)])
+ i1, i2 = self.ll_unpack_tuple(res, 2)
+ assert i1 != i2
+
def test_cast_primitive(self):
from pypy.rpython.annlowlevel import LowLevelAnnotatorPolicy
def llf(u):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit