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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
dd3da6c2
Commit
dd3da6c2
authored
Apr 07, 2011
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PEP 3118: fix for NULL Py_buffer arg
parent
538ae904
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+9
-5
Cython/Includes/numpy.pxd
Cython/Includes/numpy.pxd
+3
-0
No files found.
Cython/Compiler/Nodes.py
View file @
dd3da6c2
...
@@ -1623,20 +1623,24 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -1623,20 +1623,24 @@ class FuncDefNode(StatNode, BlockNode):
info
=
self
.
local_scope
.
arg_entries
[
1
].
cname
info
=
self
.
local_scope
.
arg_entries
[
1
].
cname
# Python 3.0 betas have a bug in memoryview which makes it call
# Python 3.0 betas have a bug in memoryview which makes it call
# getbuffer with a NULL parameter. For now we work around this;
# getbuffer with a NULL parameter. For now we work around this;
# the following
line
should be removed when this bug is fixed.
# the following
block
should be removed when this bug is fixed.
code
.
putln
(
"if (%s
== NULL) return 0;
"
%
info
)
code
.
putln
(
"if (%s
!= NULL) {
"
%
info
)
code
.
putln
(
"%s->obj = Py_None; __Pyx_INCREF(Py_None);"
%
info
)
code
.
putln
(
"%s->obj = Py_None; __Pyx_INCREF(Py_None);"
%
info
)
code
.
put_giveref
(
"%s->obj"
%
info
)
# Do not refnanny object within structs
code
.
put_giveref
(
"%s->obj"
%
info
)
# Do not refnanny object within structs
code
.
putln
(
"}"
)
def
getbuffer_error_cleanup
(
self
,
code
):
def
getbuffer_error_cleanup
(
self
,
code
):
info
=
self
.
local_scope
.
arg_entries
[
1
].
cname
info
=
self
.
local_scope
.
arg_entries
[
1
].
cname
code
.
putln
(
"if (%s != NULL && %s->obj != NULL) {"
%
(
info
,
info
))
code
.
put_gotref
(
"%s->obj"
%
info
)
code
.
put_gotref
(
"%s->obj"
%
info
)
code
.
putln
(
"__Pyx_DECREF(%s->obj); %s->obj = NULL;"
%
code
.
putln
(
"__Pyx_DECREF(%s->obj); %s->obj = NULL;"
(
info
,
info
))
%
(
info
,
info
))
code
.
putln
(
"}"
)
def
getbuffer_normal_cleanup
(
self
,
code
):
def
getbuffer_normal_cleanup
(
self
,
code
):
info
=
self
.
local_scope
.
arg_entries
[
1
].
cname
info
=
self
.
local_scope
.
arg_entries
[
1
].
cname
code
.
putln
(
"if (%s
->obj == Py_None) {"
%
info
)
code
.
putln
(
"if (%s
!= NULL && %s->obj == Py_None) {"
%
(
info
,
info
)
)
code
.
put_gotref
(
"Py_None"
)
code
.
put_gotref
(
"Py_None"
)
code
.
putln
(
"__Pyx_DECREF(Py_None); %s->obj = NULL;"
%
info
)
code
.
putln
(
"__Pyx_DECREF(Py_None); %s->obj = NULL;"
%
info
)
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
...
...
Cython/Includes/numpy.pxd
View file @
dd3da6c2
...
@@ -190,6 +190,9 @@ cdef extern from "numpy/arrayobject.h":
...
@@ -190,6 +190,9 @@ cdef extern from "numpy/arrayobject.h":
# requirements, and does not yet fullfill the PEP.
# requirements, and does not yet fullfill the PEP.
# In particular strided access is always provided regardless
# In particular strided access is always provided regardless
# of flags
# of flags
if
info
==
NULL
:
return
cdef
int
copy_shape
,
i
,
ndim
cdef
int
copy_shape
,
i
,
ndim
cdef
int
endian_detector
=
1
cdef
int
endian_detector
=
1
cdef
bint
little_endian
=
((
<
char
*>&
endian_detector
)[
0
]
!=
0
)
cdef
bint
little_endian
=
((
<
char
*>&
endian_detector
)[
0
]
!=
0
)
...
...
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