Commit ec0add58 authored by Mark Florisson's avatar Mark Florisson

Decref capsules & fix py3 numpy test output

parent 1d00d8ad
......@@ -107,7 +107,7 @@ typedef struct {
/////////////// GetAndReleaseBuffer ///////////////
#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
PyObject *getbuffer_cobj = NULL;
PyObject *getbuffer_cobj;
#if PY_VERSION_HEX >= 0x02060000
if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
......@@ -130,6 +130,7 @@ static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
#else
func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj);
#endif
Py_DECREF(getbuffer_cobj);
if (!func)
goto fail;
......@@ -144,13 +145,13 @@ static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
#if PY_VERSION_HEX < 0x02060000
fail:
#endif
Py_XDECREF(getbuffer_cobj);
return -1;
}
static void __Pyx_ReleaseBuffer(Py_buffer *view) {
PyObject* obj = view->obj;
PyObject *releasebuffer_cobj = NULL;
PyObject *obj = view->obj;
PyObject *releasebuffer_cobj;
if (!obj) return;
......@@ -179,6 +180,8 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) {
func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj);
#endif
Py_DECREF(releasebuffer_cobj);
if (!func)
goto fail;
......@@ -197,7 +200,6 @@ fail:
PyErr_WriteUnraisable(obj);
nofail:
Py_XDECREF(releasebuffer_cobj);
Py_DECREF(obj);
view->obj = NULL;
}
......
......@@ -176,12 +176,23 @@ try:
ValueError: Buffer dtype mismatch, expected 'int' but got 'float' in 'DoubleInt.y'
>>> print(test_packed_align(np.zeros((1,), dtype=np.dtype('b,i', align=False))))
array([(22, 23)],
dtype=[('f0', '|i1'), ('f1', '!i4')])
>>> print(test_unpacked_align(np.zeros((1,), dtype=np.dtype('b,i', align=True))))
[(22, 23)]
The output changed in Python 3:
>> print(test_unpacked_align(np.zeros((1,), dtype=np.dtype('b,i', align=True))))
array([(22, 23)],
dtype=[('f0', '|i1'), ('', '|V3'), ('f1', '!i4')])
->
array([(22, 23)],
dtype={'names':['f0','f1'], 'formats':['i1','!i4'], 'offsets':[0,4], 'itemsize':8, 'aligned':True})
>>> print(test_unpacked_align(np.zeros((1,), dtype=np.dtype('b,i', align=True))))
[(22, 23)]
>>> print(test_packed_align(np.zeros((1,), dtype=np.dtype('b,i', align=True)))) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
......@@ -444,12 +455,13 @@ cdef packed struct PartiallyPackedStruct2:
def test_packed_align(np.ndarray[PackedStruct] arr):
arr[0].a = 22
arr[0].b = 23
return repr(arr).replace('<', '!').replace('>', '!')
return list(arr)
def test_unpacked_align(np.ndarray[UnpackedStruct] arr):
arr[0].a = 22
arr[0].b = 23
return repr(arr).replace('<', '!').replace('>', '!')
arr[0].b = 23
# return repr(arr).replace('<', '!').replace('>', '!')
return list(arr)
def test_partially_packed_align(np.ndarray[PartiallyPackedStruct] arr):
arr[0].a = 22
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment