[pypy-commit] pypy issue2444: add test that passes but in teardown calls CPyBuffer finalizer after space is nonvalid
mattip
pypy.commits at gmail.com
Mon Dec 26 13:32:40 EST 2016
Author: Matti Picus <matti.picus at gmail.com>
Branch: issue2444
Changeset: r89233:ac6b84467eb0
Date: 2016-12-25 22:38 +0200
http://bitbucket.org/pypy/pypy/changeset/ac6b84467eb0/
Log: add test that passes but in teardown calls CPyBuffer finalizer after
space is nonvalid
diff --git a/pypy/module/cpyext/test/test_memoryobject.py b/pypy/module/cpyext/test/test_memoryobject.py
--- a/pypy/module/cpyext/test/test_memoryobject.py
+++ b/pypy/module/cpyext/test/test_memoryobject.py
@@ -63,11 +63,24 @@
vlen = view.len / view.itemsize;
PyBuffer_Release(&view);
return PyInt_FromLong(vlen);
- """)])
+ """),
+ ("test_buffer", "METH_VARARGS",
+ """
+ Py_buffer* view = NULL;
+ PyObject* obj = PyTuple_GetItem(args, 0);
+ PyObject* memoryview = PyMemoryView_FromObject(obj);
+ if (memoryview == NULL)
+ return PyInt_FromLong(-1);
+ view = PyMemoryView_GET_BUFFER(memoryview);
+ Py_DECREF(memoryview);
+ return PyInt_FromLong(view->len / view->itemsize);
+ """)])
module = self.import_module(name='buffer_test')
arr = module.PyMyArray(10)
ten = foo.get_len(arr)
assert ten == 10
+ ten = foo.test_buffer(arr)
+ assert ten == 10
@pytest.mark.skipif(only_pypy, reason='pypy only test')
def test_buffer_info(self):
More information about the pypy-commit
mailing list