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
d6d8b345
Commit
d6d8b345
authored
Apr 15, 2020
by
da-woods
Committed by
Stefan Behnel
Apr 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Release temps used for buffer indexing after use (GH-3517)
Closes
https://github.com/cython/cython/issues/3430
parent
b3c2e0d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+10
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
d6d8b345
...
...
@@ -4294,7 +4294,7 @@ class BufferIndexNode(_IndexingBaseNode):
else
:
negative_indices
=
Buffer
.
buffer_defaults
[
'negative_indices'
]
return
buffer_entry
,
Buffer
.
put_buffer_lookup_code
(
buffer_lookup_result
=
Buffer
.
put_buffer_lookup_code
(
entry
=
buffer_entry
,
index_signeds
=
[
ivar
.
type
.
signed
for
ivar
in
self
.
indices
],
index_cnames
=
index_temps
,
...
...
@@ -4303,6 +4303,9 @@ class BufferIndexNode(_IndexingBaseNode):
negative_indices
=
negative_indices
,
in_nogil_context
=
self
.
in_nogil_context
)
# must return index_temps since that cannot be released until buffer_lookup_result has been used
return
buffer_entry
,
buffer_lookup_result
,
index_temps
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
):
self
.
generate_subexpr_evaluation_code
(
code
)
self
.
generate_buffer_setitem_code
(
rhs
,
code
)
...
...
@@ -4333,7 +4336,7 @@ class BufferIndexNode(_IndexingBaseNode):
return
# Used from generate_assignment_code and InPlaceAssignmentNode
buffer_entry
,
ptrexpr
=
self
.
buffer_lookup_code
(
code
)
buffer_entry
,
ptrexpr
,
buffer_temps
=
self
.
buffer_lookup_code
(
code
)
if
self
.
buffer_type
.
dtype
.
is_pyobject
:
# Must manage refcounts. Decref what is already there
...
...
@@ -4351,6 +4354,8 @@ class BufferIndexNode(_IndexingBaseNode):
else
:
# Simple case
code
.
putln
(
"*%s %s= %s;"
%
(
ptrexpr
,
op
,
rhs
.
result
()))
for
temp
in
buffer_temps
:
code
.
funcstate
.
release_temp
(
temp
)
def
generate_result_code
(
self
,
code
):
if
is_pythran_expr
(
self
.
base
.
type
):
...
...
@@ -4362,13 +4367,15 @@ class BufferIndexNode(_IndexingBaseNode):
self
.
base
.
pythran_result
(),
pythran_indexing_code
(
self
.
indices
)))
return
buffer_entry
,
self
.
buffer_ptr_code
=
self
.
buffer_lookup_code
(
code
)
buffer_entry
,
self
.
buffer_ptr_code
,
buffer_temps
=
self
.
buffer_lookup_code
(
code
)
if
self
.
type
.
is_pyobject
:
# is_temp is True, so must pull out value and incref it.
# NOTE: object temporary results for nodes are declared
# as PyObject *, so we need a cast
code
.
putln
(
"%s = (PyObject *) *%s;"
%
(
self
.
result
(),
self
.
buffer_ptr_code
))
code
.
putln
(
"__Pyx_INCREF((PyObject*)%s);"
%
self
.
result
())
for
temp
in
buffer_temps
:
code
.
funcstate
.
release_temp
(
temp
)
class
MemoryViewIndexNode
(
BufferIndexNode
):
...
...
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