Author: Matti Picus <[email protected]>
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):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to