[pypy-commit] pypy better-PyDict_Next: add a passing test, does not exercise the c-level getter (which is NULL but should not be)
mattip
pypy.commits at gmail.com
Mon Dec 12 09:19:33 EST 2016
Author: Matti Picus <matti.picus at gmail.com>
Branch: better-PyDict_Next
Changeset: r89022:0bd4f1974653
Date: 2016-12-12 16:18 +0200
http://bitbucket.org/pypy/pypy/changeset/0bd4f1974653/
Log: add a passing test, does not exercise the c-level getter (which is
NULL but should not be)
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
@@ -181,7 +181,7 @@
raises(OperationError, space.call_method, w_proxy, 'clear')
assert api.PyDictProxy_Check(w_proxy)
- def test_typedict(self, space, api):
+ def test_typedict1(self, space, api):
py_type = make_ref(space, space.w_int)
py_dict = rffi.cast(PyTypeObjectPtr, py_type).c_tp_dict
ppos = lltype.malloc(Py_ssize_tP.TO, 1, flavor='raw')
@@ -246,3 +246,17 @@
d = {"a": 1}
raises(AttributeError, module.update, d, [("c", 2)])
+ def test_typedict2(self):
+ module = self.import_extension('foo', [
+ ("get_type_dict", "METH_O",
+ '''
+ PyObject* value = args->ob_type->tp_dict;
+ if (value == NULL) value = Py_None;
+ Py_INCREF(value);
+ return value;
+ '''),
+ ])
+ d = module.get_type_dict(1)
+ print type(d['real'])
+ assert d['real'].__get__(1, 1) == 1
+
More information about the pypy-commit
mailing list