[pypy-svn] r46278 - in pypy/dist/pypy/translator/jvm: . test
antocuni at codespeak.net
antocuni at codespeak.net
Mon Sep 3 16:08:37 CEST 2007
Author: antocuni
Date: Mon Sep 3 16:08:37 2007
New Revision: 46278
Modified:
pypy/dist/pypy/translator/jvm/constant.py
pypy/dist/pypy/translator/jvm/test/test_constant.py
Log:
don't try to access custom eq&hash functions on a null dict.
Modified: pypy/dist/pypy/translator/jvm/constant.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/constant.py (original)
+++ pypy/dist/pypy/translator/jvm/constant.py Mon Sep 3 16:08:37 2007
@@ -88,6 +88,8 @@
# key_eq is a Python function and graph is, well, a method
# graph that seems to be added to the function pointer
# somewhere. Adapted from cli/constant.py
+ if self.value is ootype.null(self.value._TYPE):
+ return
self.eq_jcls = self.db.record_delegate_standalone_func_impl(
self.value._dict.key_eq.graph)
self.hash_jcls = self.db.record_delegate_standalone_func_impl(
Modified: pypy/dist/pypy/translator/jvm/test/test_constant.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/test/test_constant.py (original)
+++ pypy/dist/pypy/translator/jvm/test/test_constant.py Mon Sep 3 16:08:37 2007
@@ -101,26 +101,25 @@
assert self.interpret(fn2, [1]) == True
def test_customdict_circular(self):
- py.test.skip("Circular dicts are not supported in JVM")
-# from pypy.rlib.objectmodel import r_dict
-# def key_eq(a, b):
-# return a.x[0] == b.x[0]
-# def key_hash(a):
-# return ord(a.x[0])
-#
-# class A:
-# def __init__(self, x):
-# self.x = x
-# a = A('foo')
-# a.dict = r_dict(key_eq, key_hash)
-# a.dict[a] = 42
-# def fn(b):
-# if b:
-# s = A('foo')
-# else:
-# s = A('bar')
-# return a.dict[s]
-# assert self.interpret(fn, [True]) == 42
+ from pypy.rlib.objectmodel import r_dict
+ def key_eq(a, b):
+ return a.x[0] == b.x[0]
+ def key_hash(a):
+ return ord(a.x[0])
+
+ class A:
+ def __init__(self, x):
+ self.x = x
+ a = A('foo')
+ a.dict = r_dict(key_eq, key_hash)
+ a.dict[a] = 42
+ def fn(b):
+ if b:
+ s = A('foo')
+ else:
+ s = A('bar')
+ return a.dict[s]
+ assert self.interpret(fn, [True]) == 42
def test_multiple_step(self):
from pypy.translator.oosupport import constant
More information about the Pypy-commit
mailing list