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
Boxiang Sun
cython
Commits
1301d2a5
Commit
1301d2a5
authored
Sep 26, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use reset-before-decref to safely clear references in closures
parent
695dc278
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
7 deletions
+21
-7
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+18
-7
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+3
-0
No files found.
Cython/Compiler/Code.py
View file @
1301d2a5
...
@@ -1321,19 +1321,30 @@ class CCodeWriter(object):
...
@@ -1321,19 +1321,30 @@ class CCodeWriter(object):
if
entry
.
type
.
is_pyobject
:
if
entry
.
type
.
is_pyobject
:
self
.
putln
(
"__Pyx_XDECREF(%s);"
%
self
.
entry_as_pyobject
(
entry
))
self
.
putln
(
"__Pyx_XDECREF(%s);"
%
self
.
entry_as_pyobject
(
entry
))
def
put_var_decref_clear
(
self
,
entry
):
if
entry
.
type
.
is_pyobject
:
self
.
putln
(
"__Pyx_DECREF(%s); %s = 0;"
%
(
self
.
entry_as_pyobject
(
entry
),
entry
.
cname
))
def
put_var_xdecref
(
self
,
entry
):
def
put_var_xdecref
(
self
,
entry
):
if
entry
.
type
.
is_pyobject
:
if
entry
.
type
.
is_pyobject
:
self
.
putln
(
"__Pyx_XDECREF(%s);"
%
self
.
entry_as_pyobject
(
entry
))
self
.
putln
(
"__Pyx_XDECREF(%s);"
%
self
.
entry_as_pyobject
(
entry
))
def
put_var_decref_clear
(
self
,
entry
):
self
.
_put_var_decref_clear
(
entry
,
null_check
=
False
)
def
put_var_xdecref_clear
(
self
,
entry
):
def
put_var_xdecref_clear
(
self
,
entry
):
self
.
_put_var_decref_clear
(
entry
,
null_check
=
True
)
def
_put_var_decref_clear
(
self
,
entry
,
null_check
):
if
entry
.
type
.
is_pyobject
:
if
entry
.
type
.
is_pyobject
:
self
.
putln
(
"__Pyx_XDECREF(%s); %s = 0;"
%
(
if
entry
.
in_closure
:
self
.
entry_as_pyobject
(
entry
),
entry
.
cname
))
# reset before DECREF to make sure closure state is
# consistent during call to DECREF()
self
.
putln
(
"__Pyx_%sCLEAR(%s);"
%
(
null_check
and
'X'
or
''
,
entry
.
cname
))
else
:
self
.
putln
(
"__Pyx_%sDECREF(%s); %s = 0;"
%
(
self
.
entry_as_pyobject
(
entry
),
entry
.
cname
,
null_check
and
'X'
or
''
,
entry
.
cname
))
def
put_var_decrefs
(
self
,
entries
,
used_only
=
0
):
def
put_var_decrefs
(
self
,
entries
,
used_only
=
0
):
for
entry
in
entries
:
for
entry
in
entries
:
...
...
Cython/Compiler/ModuleNode.py
View file @
1301d2a5
...
@@ -2966,6 +2966,9 @@ proto="""
...
@@ -2966,6 +2966,9 @@ proto="""
#define __Pyx_XGOTREF(r)
#define __Pyx_XGOTREF(r)
#define __Pyx_XGIVEREF(r)
#define __Pyx_XGIVEREF(r)
#endif /* CYTHON_REFNANNY */
#endif /* CYTHON_REFNANNY */
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
"""
,
"""
,
impl
=
"""
impl
=
"""
#if CYTHON_REFNANNY
#if CYTHON_REFNANNY
...
...
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