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
c66287f6
Commit
c66287f6
authored
Nov 20, 2014
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests, adjusted warning message, and fixed the line in PyrexTypes.
parent
b3ee89c7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
2 deletions
+99
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+1
-1
tests/errors/w_numpy_arr_as_cppvec_ref.pyx
tests/errors/w_numpy_arr_as_cppvec_ref.pyx
+55
-0
tests/errors/w_python_list_as_cppset_ref.pyx
tests/errors/w_python_list_as_cppset_ref.pyx
+41
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
c66287f6
...
...
@@ -11379,7 +11379,8 @@ class CoerceFromPyTypeNode(CoercionNode):
"Cannot convert Python object to '%s'"
%
result_type
)
elif
result_type
.
is_reference
:
warning
(
arg
.
pos
,
"Cannot pass Python object as %s reference, will pass by copy."
%
result_type
,
"Cannot pass Python object as C++ data structure "
"reference (%s &), will pass by copy."
%
result_type
,
level
=
1
)
if
self
.
type
.
is_string
or
self
.
type
.
is_pyunicode_ptr
:
if
self
.
arg
.
is_name
and
self
.
arg
.
entry
and
self
.
arg
.
entry
.
is_pyglobal
:
...
...
Cython/Compiler/PyrexTypes.py
View file @
c66287f6
...
...
@@ -3373,7 +3373,7 @@ class CppClassType(CType):
return
self
if
self
.
templates
is
None
:
self
.
templates
=
[]
key
=
tuple
(
values
.
items
()
+
[
is_reference
])
# Python 3?
key
=
tuple
(
values
.
items
()
)
+
(
is_reference
,)
if
key
in
self
.
specializations
:
return
self
.
specializations
[
key
]
template_values
=
[
t
.
specialize
(
values
)
for
t
in
self
.
templates
]
...
...
tests/errors/w_numpy_arr_as_cppvec_ref.pyx
0 → 100644
View file @
c66287f6
# mode: error
# tag: werror
import
numpy
as
np
cimport
numpy
as
np
from
libcpp.vector
cimport
vector
cdef
extern
from
*
:
void
cpp_function_vector1
(
vector
[
int
])
void
cpp_function_vector2
(
vector
[
int
]
&
)
void
cpp_function_2_vec_refs
(
vector
[
int
]
&
,
vector
[
int
]
&
)
def
main
():
cdef
np
.
ndarray
[
int
,
ndim
=
1
,
mode
=
"c"
]
arr
=
np
.
zeros
(
10
,
dtype
=
'intc'
)
cpp_function_vector1
(
arr
)
cpp_function_vector2
(
arr
)
cpp_function_vector2
(
arr
)
cpp_function_2_vec_refs
(
arr
,
arr
)
cdef
vector
[
int
]
vec
vec
.
push_back
(
0
)
cpp_function_vector2
(
vec
)
_ERRORS
=
"""
17:28: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
18:28: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
19:31: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
19:36: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
31:15: '<init>' redeclared
31:15: '<init>' redeclared
32:15: '<init>' redeclared
32:15: '<init>' redeclared
32:15: '<init>' redeclared
33:15: '<init>' redeclared
33:15: '<init>' redeclared
33:15: '<init>' redeclared
34:15: '<init>' redeclared
44:19: 'assign' redeclared
44:19: 'assign' redeclared
45:35: 'assign' redeclared
55:22: 'erase' redeclared
55:22: 'erase' redeclared
56:22: 'erase' redeclared
58:23: 'insert' redeclared
58:23: 'insert' redeclared
59:19: 'insert' redeclared
59:19: 'insert' redeclared
59:19: 'insert' redeclared
60:19: 'insert' redeclared
69:19: 'resize' redeclared
69:19: 'resize' redeclared
70:19: 'resize' redeclared
"""
tests/errors/w_python_list_as_cppset_ref.pyx
0 → 100644
View file @
c66287f6
# mode: error
# tag: werror
from
libcpp.set
cimport
set
cdef
extern
from
"foo.cpp"
:
void
cpp_function_set1
(
set
[
int
])
void
cpp_function_set2
(
set
[
int
]
&
)
def
pass_py_obj_as_cpp_cont_ref
():
cdef
list
ordered_set
=
[
0
,
0
,
0
,
0
,
0
]
cpp_function_set1
(
ordered_set
)
cpp_function_set2
(
ordered_set
)
_ERRORS
=
"""
5:13: '<init>' redeclared
5:13: '<init>' redeclared
6:13: '<init>' redeclared
6:13: '<init>' redeclared
6:13: '<init>' redeclared
6:13: '<init>' redeclared
6:13: '<init>' redeclared
7:13: '<init>' redeclared
7:13: '<init>' redeclared
7:13: '<init>' redeclared
14:33: Cannot pass Python object as C++ data structure reference (set[int] &), will pass by copy.
21:12: '<init>' redeclared
21:12: '<init>' redeclared
22:12: '<init>' redeclared
40:18: 'erase' redeclared
40:18: 'erase' redeclared
41:18: 'erase' redeclared
41:18: 'erase' redeclared
41:18: 'erase' redeclared
42:20: 'erase' redeclared
45:35: 'insert' redeclared
45:35: 'insert' redeclared
46:23: 'insert' redeclared
"""
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