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
Gwenaël Samain
cython
Commits
6a3711d2
Commit
6a3711d2
authored
Sep 05, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update temp ref expression after analyse_types() if node was replaced
parent
5eab4419
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
Cython/Compiler/UtilNodes.py
Cython/Compiler/UtilNodes.py
+9
-0
tests/memoryview/memoryview.pyx
tests/memoryview/memoryview.pyx
+11
-0
No files found.
Cython/Compiler/UtilNodes.py
View file @
6a3711d2
...
...
@@ -155,6 +155,11 @@ class ResultRefNode(AtomicExprNode):
else
:
return
()
def
update_expression
(
self
,
expression
):
self
.
expression
=
expression
if
hasattr
(
expression
,
"type"
):
self
.
type
=
expression
.
type
def
analyse_types
(
self
,
env
):
if
self
.
expression
is
not
None
:
self
.
type
=
self
.
expression
.
type
...
...
@@ -256,6 +261,7 @@ class LetNodeMixin:
code
.
put_decref_clear
(
self
.
temp
,
self
.
temp_type
)
code
.
funcstate
.
release_temp
(
self
.
temp
)
class
EvalWithTempExprNode
(
ExprNodes
.
ExprNode
,
LetNodeMixin
):
# A wrapper around a subexpression that moves an expression into a
# temp variable and provides it to the subexpression.
...
...
@@ -277,6 +283,7 @@ class EvalWithTempExprNode(ExprNodes.ExprNode, LetNodeMixin):
def
analyse_types
(
self
,
env
):
self
.
temp_expression
=
self
.
temp_expression
.
analyse_types
(
env
)
self
.
lazy_temp
.
update_expression
(
self
.
temp_expression
)
# overwrite in case it changed
self
.
subexpression
=
self
.
subexpression
.
analyse_types
(
env
)
self
.
type
=
self
.
subexpression
.
type
return
self
...
...
@@ -292,8 +299,10 @@ class EvalWithTempExprNode(ExprNodes.ExprNode, LetNodeMixin):
self
.
subexpression
.
generate_evaluation_code
(
code
)
self
.
teardown_temp_expr
(
code
)
LetRefNode
=
ResultRefNode
class
LetNode
(
Nodes
.
StatNode
,
LetNodeMixin
):
# Implements a local temporary variable scope. Imagine this
# syntax being present:
...
...
tests/memoryview/memoryview.pyx
View file @
6a3711d2
...
...
@@ -1022,3 +1022,14 @@ def test_cpython_offbyone_issue_23349():
cdef
unsigned
char
[:]
v
=
bytearray
(
b"testing"
)
# the following returns 'estingt' without the workaround
return
bytearray
(
v
).
decode
(
'ascii'
)
cdef
int
min_max_tree_restructuring
():
"""
>>> min_max_tree_restructuring()
"""
cdef
char
a
[
5
]
a
=
[
1
,
2
,
3
,
4
,
5
]
cdef
char
[:]
aview
=
a
return
max
(
<
char
>
1
,
aview
[
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