Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
ec0add58
Commit
ec0add58
authored
Mar 30, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decref capsules & fix py3 numpy test output
parent
1d00d8ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
11 deletions
+25
-11
Cython/Utility/Buffer.c
Cython/Utility/Buffer.c
+7
-5
tests/run/numpy_test.pyx
tests/run/numpy_test.pyx
+18
-6
No files found.
Cython/Utility/Buffer.c
View file @
ec0add58
...
...
@@ -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
;
}
...
...
tests/run/numpy_test.pyx
View file @
ec0add58
...
...
@@ -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
(
'>'
,
'!'
)
# return repr(arr).replace('<', '!').replace('>', '!')
return
list
(
arr
)
def
test_partially_packed_align
(
np
.
ndarray
[
PartiallyPackedStruct
]
arr
):
arr
[
0
].
a
=
22
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment