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
956316e0
Commit
956316e0
authored
Apr 05, 2013
by
Nikita Nemkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix C++ compilation error when if/else expression has extension class type.
parent
6b1c2ef1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-0
tests/run/if_else_expr.pyx
tests/run/if_else_expr.pyx
+18
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
956316e0
...
...
@@ -9234,6 +9234,8 @@ class CondExprNode(ExprNode):
self
.
true_val
=
self
.
true_val
.
analyse_types
(
env
)
self
.
false_val
=
self
.
false_val
.
analyse_types
(
env
)
self
.
type
=
PyrexTypes
.
independent_spanning_type
(
self
.
true_val
.
type
,
self
.
false_val
.
type
)
if
self
.
type
.
is_pyobject
:
self
.
result_ctype
=
py_object_type
if
self
.
true_val
.
type
.
is_pyobject
or
self
.
false_val
.
type
.
is_pyobject
:
self
.
true_val
=
self
.
true_val
.
coerce_to
(
self
.
type
,
env
)
self
.
false_val
=
self
.
false_val
.
coerce_to
(
self
.
type
,
env
)
...
...
tests/run/if_else_expr.pyx
View file @
956316e0
# mode: run
# tag: if_else_expr
# tag: condexpr
cimport
cython
cdef
class
Foo
:
cdef
dict
data
def
__repr__
(
self
):
return
'<Foo>'
...
...
@@ -14,3 +18,16 @@ cpdef test_type_cast(Foo obj, cond):
<Foo>
"""
return
[
obj
]
if
cond
else
obj
cdef
func
(
Foo
foo
,
dict
data
):
return
foo
,
data
@
cython
.
test_fail_if_path_exists
(
'//PyTypeTestNode'
)
def
test_cpp_pyobject_cast
(
Foo
obj1
,
Foo
obj2
,
cond
):
"""
>>> test_cpp_pyobject_cast(Foo(), Foo(), True)
(<Foo>, None)
"""
return
func
(
obj1
if
cond
else
obj2
,
obj1
.
data
if
cond
else
obj2
.
data
)
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