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
Kirill Smelkov
cython
Commits
1c85a781
Commit
1c85a781
authored
Jan 03, 2018
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix incompatible pointer assingments for bool binops.
Fixes #2059.
parent
5ae0b7cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+7
-6
tests/run/or.pyx
tests/run/or.pyx
+15
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
1c85a781
...
...
@@ -11718,7 +11718,7 @@ class BoolBinopNode(ExprNode):
operator
=
self
.
operator
,
operand1
=
operand1
,
operand2
=
operand2
)
def
generate_bool_evaluation_code
(
self
,
code
,
final_result_temp
,
and_label
,
or_label
,
end_label
,
fall_through
):
def
generate_bool_evaluation_code
(
self
,
code
,
final_result_temp
,
final_result_type
,
and_label
,
or_label
,
end_label
,
fall_through
):
code
.
mark_pos
(
self
.
pos
)
outer_labels
=
(
and_label
,
or_label
)
...
...
@@ -11727,19 +11727,20 @@ class BoolBinopNode(ExprNode):
else
:
my_label
=
or_label
=
code
.
new_label
(
'next_or'
)
self
.
operand1
.
generate_bool_evaluation_code
(
code
,
final_result_temp
,
and_label
,
or_label
,
end_label
,
my_label
)
code
,
final_result_temp
,
final_result_type
,
and_label
,
or_label
,
end_label
,
my_label
)
and_label
,
or_label
=
outer_labels
code
.
put_label
(
my_label
)
self
.
operand2
.
generate_bool_evaluation_code
(
code
,
final_result_temp
,
and_label
,
or_label
,
end_label
,
fall_through
)
code
,
final_result_temp
,
final_result_type
,
and_label
,
or_label
,
end_label
,
fall_through
)
def
generate_evaluation_code
(
self
,
code
):
self
.
allocate_temp_result
(
code
)
result_type
=
PyrexTypes
.
py_object_type
if
self
.
type
.
is_pyobject
else
self
.
type
or_label
=
and_label
=
None
end_label
=
code
.
new_label
(
'bool_binop_done'
)
self
.
generate_bool_evaluation_code
(
code
,
self
.
result
(),
and_label
,
or_label
,
end_label
,
end_label
)
self
.
generate_bool_evaluation_code
(
code
,
self
.
result
(),
result_type
,
and_label
,
or_label
,
end_label
,
end_label
)
code
.
put_label
(
end_label
)
gil_message
=
"Truth-testing Python object"
...
...
@@ -11824,7 +11825,7 @@ class BoolBinopResultNode(ExprNode):
test_result
=
self
.
arg
.
result
()
return
(
test_result
,
self
.
arg
.
type
.
is_pyobject
)
def
generate_bool_evaluation_code
(
self
,
code
,
final_result_temp
,
and_label
,
or_label
,
end_label
,
fall_through
):
def
generate_bool_evaluation_code
(
self
,
code
,
final_result_temp
,
final_result_type
,
and_label
,
or_label
,
end_label
,
fall_through
):
code
.
mark_pos
(
self
.
pos
)
# x => x
...
...
@@ -11867,7 +11868,7 @@ class BoolBinopResultNode(ExprNode):
code
.
putln
(
"} else {"
)
self
.
value
.
generate_evaluation_code
(
code
)
self
.
value
.
make_owned_reference
(
code
)
code
.
putln
(
"%s = %s;"
%
(
final_result_temp
,
self
.
value
.
result
(
)))
code
.
putln
(
"%s = %s;"
%
(
final_result_temp
,
self
.
value
.
result
_as
(
final_result_type
)))
self
.
value
.
generate_post_assignment_code
(
code
)
# disposal: {not (and_label and or_label) [else]}
self
.
arg
.
generate_disposal_code
(
code
)
...
...
tests/run/or.pyx
View file @
1c85a781
...
...
@@ -58,3 +58,18 @@ def or2_literal():
5
"""
return
False
or
5
cdef
class
A
(
object
):
def
__repr__
(
self
):
return
"A"
def
test_GH2059_missing_cast
():
"""
>>> test_GH2059_missing_cast()
(A, A)
"""
cdef
A
a
=
A
()
cdef
object
o
=
None
cdef
A
a_first
=
a
or
o
cdef
A
a_second
=
o
or
a
return
a_first
,
a_second
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