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
075e025f
Commit
075e025f
authored
Nov 23, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reimplement warning when Python objects coerce to C++ references
parent
9a0983ec
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+7
-1
tests/errors/w_python_list_as_cppset_ref.pyx
tests/errors/w_python_list_as_cppset_ref.pyx
+3
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
075e025f
...
...
@@ -714,7 +714,8 @@ class ExprNode(Node):
if
self
.
check_for_coercion_error
(
dst_type
,
env
):
return
self
if
dst_type
.
is_reference
and
not
src_type
.
is_reference
:
used_as_reference
=
dst_type
.
is_reference
if
used_as_reference
and
not
src_type
.
is_reference
:
dst_type
=
dst_type
.
ref_base_type
if
src_type
.
is_const
:
...
...
@@ -781,6 +782,11 @@ class ExprNode(Node):
if
src
.
constant_result
is
not
None
:
src
=
PyTypeTestNode
(
src
,
dst_type
,
env
)
elif
src
.
type
.
is_pyobject
:
if
used_as_reference
:
warning
(
self
.
pos
,
"Cannot pass Python object as C++ data structure reference (%s &), will pass by copy."
%
dst_type
,
level
=
1
)
src
=
CoerceFromPyTypeNode
(
dst_type
,
src
,
env
)
elif
(
dst_type
.
is_complex
and
src_type
!=
dst_type
...
...
tests/errors/w_python_list_as_cppset_ref.pyx
View file @
075e025f
...
...
@@ -3,9 +3,9 @@
from
libcpp.set
cimport
set
cdef
extern
from
"foo.cpp"
:
void
cpp_function_set1
(
set
[
int
])
void
cpp_function_set2
(
set
[
int
]
&
)
cdef
extern
from
*
:
void
cpp_function_set1
(
set
[
int
]
arg
)
void
cpp_function_set2
(
set
[
int
]
&
arg
)
def
pass_py_obj_as_cpp_cont_ref
():
...
...
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