Author: Ronan Lamy <[email protected]>
Branch: issue2444
Changeset: r89243:9999f71d34a9
Date: 2016-12-27 12:37 +0100
http://bitbucket.org/pypy/pypy/changeset/9999f71d34a9/

Log:    Delay PyMemoryViewObject configuration so we can use the standard
        mechanism to configure Py_buffer

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -630,7 +630,8 @@
 PyVarObjectStruct = cpython_struct("PyVarObject", PyVarObjectFields)
 PyVarObject = lltype.Ptr(PyVarObjectStruct)
 
-Py_buffer = rffi.CStruct( "Py_buffer", 
+Py_buffer = cpython_struct(
+    "Py_buffer", (
         ('buf', rffi.VOIDP),
         ('obj', PyObject),
         ('len', Py_ssize_t),
@@ -647,10 +648,7 @@
         ('_strides', rffi.CFixedArray(Py_ssize_t, Py_MAX_NDIMS)),
         #('smalltable', rffi.CFixedArray(Py_ssize_t, 2)),
         ('internal', rffi.VOIDP),
-        hints={'size': 6 * rffi.sizeof(Py_ssize_tP) + 2 * 
rffi.sizeof(Py_ssize_t) +
-                       2 * rffi.sizeof(rffi.INT_real) + 
rffi.sizeof(rffi.CCHARP) +
-                       Py_MAX_FMT * rffi.sizeof(rffi.UCHAR) +
-                       2 * Py_MAX_NDIMS * rffi.sizeof(Py_ssize_t)})
+))
 Py_bufferP = lltype.Ptr(Py_buffer)
 
 @specialize.memo()
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
@@ -17,7 +17,9 @@
 PyMemoryViewObject = lltype.Ptr(PyMemoryViewObjectStruct)
 PyMemoryViewObjectFields = PyObjectFields + \
     (("view", Py_buffer),)
-cpython_struct("PyMemoryViewObject", PyMemoryViewObjectFields, 
PyMemoryViewObjectStruct)
+cpython_struct(
+    "PyMemoryViewObject", PyMemoryViewObjectFields, PyMemoryViewObjectStruct,
+    level=2)
 
 @bootstrap_function
 def init_memoryobject(space):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to