[pypy-commit] pypy cpyext-ext: (rlamy) fix for testing - cache the function

mattip pypy.commits at gmail.com
Mon Feb 22 08:04:58 EST 2016


Author: mattip <matti.picus at gmail.com>
Branch: cpyext-ext
Changeset: r82389:a795cb8e3138
Date: 2016-02-21 18:29 +0100
http://bitbucket.org/pypy/pypy/changeset/a795cb8e3138/

Log:	(rlamy) fix for testing - cache the function

diff --git a/pypy/module/cpyext/dictobject.py b/pypy/module/cpyext/dictobject.py
--- a/pypy/module/cpyext/dictobject.py
+++ b/pypy/module/cpyext/dictobject.py
@@ -230,6 +230,12 @@
 
 @specialize.memo()
 def make_frozendict(space):
+    if space not in _frozendict_cache:
+        _frozendict_cache[space] = _make_frozendict(space)
+    return _frozendict_cache[space]
+        
+_frozendict_cache = {}
+def _make_frozendict(space):
     return space.appexec([], '''():
     import _abcoll
     class FrozenDict(_abcoll.Mapping):
diff --git a/pypy/module/cpyext/test/test_dictobject.py b/pypy/module/cpyext/test/test_dictobject.py
--- a/pypy/module/cpyext/test/test_dictobject.py
+++ b/pypy/module/cpyext/test/test_dictobject.py
@@ -161,17 +161,13 @@
 
     def test_dictproxy(self, space, api):
         w_dict = space.sys.get('modules')
+        w_proxy = api.PyDictProxy_New(w_dict)
         assert space.contains_w(w_proxy, space.wrap('sys'))
         raises(OperationError, space.setitem,
                w_proxy, space.wrap('sys'), space.w_None)
         raises(OperationError, space.delitem,
                w_proxy, space.wrap('sys'))
         raises(OperationError, space.call_method, w_proxy, 'clear')
-
-
-    @py.test.mark.xfail(reason='make_frozendict memoize only works translated')
-    def test_dictproxy(self, space, api):
-        w_proxy = api.PyDictProxy_New(w_dict)
         assert api.PyDictProxy_Check(w_proxy)
     
 class AppTestDictObject(AppTestCpythonExtensionBase):
@@ -187,7 +183,6 @@
                      return NULL;
                  proxydict = PyDictProxy_New(dict);
                  Py_DECREF(dict);
-                 /* when memoize works untranslated, add these tests
                  if (!PyDictProxy_Check(proxydict)) {
                     Py_DECREF(proxydict);
                     PyErr_SetNone(PyExc_ValueError);
@@ -198,7 +193,6 @@
                     PyErr_SetNone(PyExc_ValueError);
                     return NULL;
                  }
-                 */
                  i = PyObject_Size(proxydict);
                  Py_DECREF(proxydict);
                  return PyLong_FromLong(i); 


More information about the pypy-commit mailing list