[pypy-svn] r68492 - in pypy/branch/gc-hash/pypy/rpython/lltypesystem: . test
arigo at codespeak.net
arigo at codespeak.net
Thu Oct 15 15:52:54 CEST 2009
Author: arigo
Date: Thu Oct 15 15:52:54 2009
New Revision: 68492
Modified:
pypy/branch/gc-hash/pypy/rpython/lltypesystem/lltype.py
pypy/branch/gc-hash/pypy/rpython/lltypesystem/test/test_lltype.py
Log:
Test and fix.
Modified: pypy/branch/gc-hash/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/branch/gc-hash/pypy/rpython/lltypesystem/lltype.py (original)
+++ pypy/branch/gc-hash/pypy/rpython/lltypesystem/lltype.py Thu Oct 15 15:52:54 2009
@@ -1124,7 +1124,11 @@
try:
return p._obj._hash_cache_
except AttributeError:
- result = p._obj._hash_cache_ = hash(p._obj)
+ result = hash(p._obj)
+ try:
+ p._obj._hash_cache_ = result
+ except AttributeError:
+ pass
return result
class _ptr(_abstract_ptr):
Modified: pypy/branch/gc-hash/pypy/rpython/lltypesystem/test/test_lltype.py
==============================================================================
--- pypy/branch/gc-hash/pypy/rpython/lltypesystem/test/test_lltype.py (original)
+++ pypy/branch/gc-hash/pypy/rpython/lltypesystem/test/test_lltype.py Thu Oct 15 15:52:54 2009
@@ -768,3 +768,10 @@
from pypy.rpython.lltypesystem import llmemory
p3 = cast_opaque_ptr(llmemory.GCREF, s3)
assert -123 == identityhash(p3)
+
+ A = GcArray(Signed)
+ a = malloc(A, 3)
+ hash1 = identityhash(a)
+ assert hash1 == identityhash(a)
+ p = cast_opaque_ptr(llmemory.GCREF, a)
+ assert hash1 == identityhash(p)
More information about the Pypy-commit
mailing list