[pypy-svn] r65542 - in pypy/branch/pyjitpl5-experiments/pypy/rpython: ootypesystem test
antocuni at codespeak.net
antocuni at codespeak.net
Tue Jun 2 14:21:03 CEST 2009
Author: antocuni
Date: Tue Jun 2 14:20:59 2009
New Revision: 65542
Modified:
pypy/branch/pyjitpl5-experiments/pypy/rpython/ootypesystem/rclass.py
pypy/branch/pyjitpl5-experiments/pypy/rpython/test/test_rclass.py
Log:
don't crash when trying to compute the hash of a null instance on ootype
Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/ootypesystem/rclass.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/rpython/ootypesystem/rclass.py (original)
+++ pypy/branch/pyjitpl5-experiments/pypy/rpython/ootypesystem/rclass.py Tue Jun 2 14:20:59 2009
@@ -570,6 +570,8 @@
def ll_inst_hash(ins):
+ if not ins:
+ return 0
cached = ins._hash_cache_
if cached == 0:
cached = ins._hash_cache_ = ootype.ooidentityhash(ins)
Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/test/test_rclass.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/rpython/test/test_rclass.py (original)
+++ pypy/branch/pyjitpl5-experiments/pypy/rpython/test/test_rclass.py Tue Jun 2 14:20:59 2009
@@ -661,6 +661,18 @@
return a.revealconst(1) + b.revealconst(2) + a.revealconst(3)
assert self.interpret(fn, []) == 3 + 8 + 9
+ def test_hash_of_none(self):
+ class A:
+ pass
+ def fn(x):
+ if x:
+ obj = A()
+ else:
+ obj = None
+ return hash(obj)
+ res = self.interpret(fn, [0])
+ assert res == 0
+
class TestLltype(BaseTestRclass, LLRtypeMixin):
More information about the Pypy-commit
mailing list