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
9ea6a398
Commit
9ea6a398
authored
Jan 06, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use assignments, not (buggy) control flow, for arg incref decision.
parent
42c6c6f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
5 deletions
+4
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-4
tests/run/arg_incref.pyx
tests/run/arg_incref.pyx
+1
-1
No files found.
Cython/Compiler/Nodes.py
View file @
9ea6a398
...
...
@@ -1135,7 +1135,7 @@ class FuncDefNode(StatNode, BlockNode):
# If an argument is assigned to in the body, we must
# incref it to properly keep track of refcounts.
for
entry
in
lenv
.
arg_entries
:
if
entry
.
type
.
is_pyobject
and
lenv
.
control_flow
.
get_state
((
entry
.
name
,
'source'
))
!=
'arg'
:
if
entry
.
type
.
is_pyobject
and
entry
.
assignments
:
code
.
put_var_incref
(
entry
)
# ----- Initialise local variables
for
entry
in
lenv
.
var_entries
:
...
...
@@ -1238,11 +1238,10 @@ class FuncDefNode(StatNode, BlockNode):
# Decref any increfed args
for
entry
in
lenv
.
arg_entries
:
if
entry
.
type
.
is_pyobject
:
src
=
lenv
.
control_flow
.
get_state
((
entry
.
name
,
'source'
))
if
entry
.
in_closure
and
src
==
'arg'
:
if
entry
.
in_closure
and
not
entry
.
assignments
:
code
.
put_var_incref
(
entry
)
code
.
put_var_giveref
(
entry
)
elif
not
entry
.
in_closure
and
src
!=
'arg'
:
elif
not
entry
.
in_closure
and
entry
.
assignments
:
code
.
put_var_decref
(
entry
)
if
self
.
needs_closure
:
code
.
put_decref
(
Naming
.
cur_scope_cname
,
lenv
.
scope_class
.
type
)
...
...
tests/run/arg_incref.pyx
View file @
9ea6a398
def
f
(
dict
d
):
def
f
(
dict
d
,
x
=
4
):
"""
>>> f({1:1, 2:2})
[1, 2]
...
...
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