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
b33a60bc
Commit
b33a60bc
authored
Feb 11, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix cascaded assignment bug with builtin call as rhs
parent
be9677c8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
8 deletions
+89
-8
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+36
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+4
-1
tests/run/cascadedassignment.pyx
tests/run/cascadedassignment.pyx
+49
-0
tests/run/returnparassign.pyx
tests/run/returnparassign.pyx
+0
-7
No files found.
Cython/Compiler/ExprNodes.py
View file @
b33a60bc
...
...
@@ -9144,6 +9144,42 @@ class CoerceToTempNode(CoercionNode):
code
.
put_incref_memoryviewslice
(
self
.
result
(),
not
self
.
in_nogil_context
)
class
ProxyNode
(
CoercionNode
):
"""
A node that should not be replaced by transforms or other means,
and hence can be useful to wrap the argument to a clone node
MyNode -> ProxyNode -> ArgNode
CloneNode -^
"""
def
__init__
(
self
,
arg
):
super
(
ProxyNode
,
self
).
__init__
(
arg
)
self
.
type
=
arg
.
type
def
generate_result_code
(
self
,
code
):
self
.
arg
.
generate_result_code
(
code
)
def
result
(
self
):
return
self
.
arg
.
result
()
def
is_simple
(
self
):
return
self
.
arg
.
is_simple
()
def
may_be_none
(
self
):
return
self
.
arg
.
may_be_none
()
def
generate_evaluation_code
(
self
,
code
):
self
.
arg
.
generate_evaluation_code
(
code
)
def
generate_result_code
(
self
,
code
):
self
.
arg
.
generate_result_code
(
code
)
def
generate_disposal_code
(
self
,
code
):
self
.
arg
.
generate_disposal_code
(
code
)
def
free_temps
(
self
,
code
):
self
.
arg
.
free_temps
(
code
)
class
CloneNode
(
CoercionNode
):
# This node is employed when the result of another node needs
...
...
Cython/Compiler/Nodes.py
View file @
b33a60bc
...
...
@@ -4813,13 +4813,16 @@ class CascadedAssignmentNode(AssignmentNode):
lhs
.
analyse_target_declaration
(
env
)
def
analyse_types
(
self
,
env
,
use_temp
=
0
):
from
ExprNodes
import
CloneNode
,
ProxyNode
self
.
rhs
.
analyse_types
(
env
)
if
not
self
.
rhs
.
is_simple
():
if
use_temp
:
self
.
rhs
=
self
.
rhs
.
coerce_to_temp
(
env
)
else
:
self
.
rhs
=
self
.
rhs
.
coerce_to_simple
(
env
)
from
ExprNodes
import
CloneNode
self
.
rhs
=
ProxyNode
(
self
.
rhs
)
self
.
coerced_rhs_list
=
[]
for
lhs
in
self
.
lhs_list
:
lhs
.
analyse_target_types
(
env
)
...
...
tests/run/cascadedassignment.pyx
0 → 100644
View file @
b33a60bc
import
cython
def
test_cascaded_assignment_simple
():
"""
>>> test_cascaded_assignment_simple()
5
"""
a
=
b
=
c
=
5
return
a
def
test_cascaded_assignment_typed
():
"""
>>> test_cascaded_assignment_typed()
int Python object double
(5, 5, 5.0)
"""
cdef
int
a
cdef
object
b
cdef
double
c
a
=
b
=
c
=
5
print
cython
.
typeof
(
a
),
cython
.
typeof
(
b
),
cython
.
typeof
(
c
)
return
a
,
b
,
c
def
test_cascaded_assignment_builtin_expr
():
"""
This test is useful as previously the rhs expr node got replaced resulting
in CloneNode generating None in the C source.
>>> test_cascaded_assignment_builtin_expr()
(10.0, 10.0, 10.0)
"""
a
=
b
=
c
=
float
(
10
)
return
a
,
b
,
c
def
expr
():
print
"expr called"
return
10
def
test_cascaded_assignment_evaluate_expr
():
"""
>>> test_cascaded_assignment_evaluate_expr()
expr called
(10.0, 10.0, 10.0)
"""
a
=
b
=
c
=
float
(
expr
())
return
a
,
b
,
c
tests/run/returnparassign.pyx
deleted
100644 → 0
View file @
be9677c8
def
test
():
"""
>>> test()
5
"""
a
=
b
=
c
=
5
return
a
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