[pypy-commit] pypy default: make sure test of PyObject_GetBuffer runs to completion, fix implementation

mattip pypy.commits at gmail.com
Fri Sep 9 08:40:40 EDT 2016


Author: Matti Picus <matti.picus at gmail.com>
Branch: 
Changeset: r86975:dcd57351c263
Date: 2016-09-09 15:13 +0300
http://bitbucket.org/pypy/pypy/changeset/dcd57351c263/

Log:	make sure test of PyObject_GetBuffer runs to completion, fix
	implementation

diff --git a/pypy/module/cpyext/memoryobject.py b/pypy/module/cpyext/memoryobject.py
--- a/pypy/module/cpyext/memoryobject.py
+++ b/pypy/module/cpyext/memoryobject.py
@@ -33,8 +33,8 @@
         view.c_buf = rffi.cast(rffi.VOIDP, buf.get_raw_address())
     except ValueError:
         raise BufferError("could not create buffer from object")
-    return fill_Py_buffer(space, w_obj, view, flags)
     view.c_obj = make_ref(space, w_obj)
+    return fill_Py_buffer(space, buf, view)
 
 def fill_Py_buffer(space, buf, view):    
     # c_buf, c_obj have been filled in
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
@@ -43,14 +43,10 @@
         from _numpypy import multiarray as np
         module = self.import_module(name='buffer_test')
         get_buffer_info = module.get_buffer_info
-        # test_export_flags from numpy test_multiarray
         raises(ValueError, get_buffer_info, np.arange(5)[::2], ('SIMPLE',))
-        # test_relaxed_strides from numpy test_multiarray
-        arr = np.zeros((1, 10))
-        if arr.flags.f_contiguous:
-            shape, strides = get_buffer_info(arr, ['F_CONTIGUOUS'])
-            assert strides[0] == 8
-            arr = np.ones((10, 1), order='F')
-            shape, strides = get_buffer_info(arr, ['C_CONTIGUOUS'])
-            assert strides[-1] == 8
-
+        arr = np.zeros((1, 10), order='F')
+        shape, strides = get_buffer_info(arr, ['F_CONTIGUOUS'])
+        assert strides[0] == 8
+        arr = np.zeros((10, 1), order='C')
+        shape, strides = get_buffer_info(arr, ['C_CONTIGUOUS'])
+        assert strides[-1] == 8


More information about the pypy-commit mailing list