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
14a5d28b
Commit
14a5d28b
authored
Nov 28, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't issue conversion from error type & fix little cython.array cast bug
parent
b7c8af96
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+8
-8
tests/errors/memview_declarations.pyx
tests/errors/memview_declarations.pyx
+5
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
14a5d28b
...
@@ -639,7 +639,7 @@ class ExprNode(Node):
...
@@ -639,7 +639,7 @@ class ExprNode(Node):
elif
src
.
type
.
is_array
:
elif
src
.
type
.
is_array
:
src
=
CythonArrayNode
.
from_carray
(
src
,
env
).
coerce_to
(
src
=
CythonArrayNode
.
from_carray
(
src
,
env
).
coerce_to
(
dst_type
,
env
)
dst_type
,
env
)
el
se
:
el
if
not
src_type
.
is_error
:
error
(
self
.
pos
,
error
(
self
.
pos
,
"Cannot convert '%s' to memoryviewslice"
%
"Cannot convert '%s' to memoryviewslice"
%
(
src_type
,))
(
src_type
,))
...
@@ -6818,18 +6818,21 @@ class CythonArrayNode(ExprNode):
...
@@ -6818,18 +6818,21 @@ class CythonArrayNode(ExprNode):
# Base type of the pointer or C array we are converting
# Base type of the pointer or C array we are converting
base_type
=
self
.
operand
.
type
base_type
=
self
.
operand
.
type
if
not
self
.
operand
.
type
.
is_ptr
and
not
self
.
operand
.
type
.
is_array
:
return
error
(
self
.
operand
.
pos
,
ERR_NOT_POINTER
)
# Dimension sizes of C array
# Dimension sizes of C array
array_dimension_sizes
=
[]
array_dimension_sizes
=
[]
if
base_type
.
is_array
:
if
base_type
.
is_array
:
while
base_type
.
is_array
:
while
base_type
.
is_array
:
array_dimension_sizes
.
append
(
base_type
.
size
)
array_dimension_sizes
.
append
(
base_type
.
size
)
base_type
=
base_type
.
base_type
base_type
=
base_type
.
base_type
el
se
:
el
if
base_type
.
is_ptr
:
base_type
=
base_type
.
base_type
base_type
=
base_type
.
base_type
else
:
return
error
()
if
not
self
.
operand
.
type
.
is_ptr
and
not
self
.
operand
.
type
.
is_array
:
if
not
base_type
.
same_as
(
array_dtype
):
return
error
(
self
.
operand
.
pos
,
ERR_NOT_POINTER
)
elif
not
base_type
.
same_as
(
array_dtype
):
return
error
(
self
.
operand
.
pos
,
ERR_BASE_TYPE
)
return
error
(
self
.
operand
.
pos
,
ERR_BASE_TYPE
)
elif
self
.
operand
.
type
.
is_array
and
len
(
array_dimension_sizes
)
!=
ndim
:
elif
self
.
operand
.
type
.
is_array
and
len
(
array_dimension_sizes
)
!=
ndim
:
return
error
(
self
.
operand
.
pos
,
return
error
(
self
.
operand
.
pos
,
...
@@ -6859,9 +6862,6 @@ class CythonArrayNode(ExprNode):
...
@@ -6859,9 +6862,6 @@ class CythonArrayNode(ExprNode):
self
.
shapes
.
append
(
shape
)
self
.
shapes
.
append
(
shape
)
if
not
axis
.
stop
.
type
.
is_int
:
return
error
(
axis
.
stop
.
pos
,
"Expected an integer type"
)
first_or_last
=
axis_no
in
(
0
,
ndim
-
1
)
first_or_last
=
axis_no
in
(
0
,
ndim
-
1
)
if
not
axis
.
step
.
is_none
and
first_or_last
:
if
not
axis
.
step
.
is_none
and
first_or_last
:
axis
.
step
.
analyse_types
(
env
)
axis
.
step
.
analyse_types
(
env
)
...
...
tests/errors/memview_declarations.pyx
View file @
14a5d28b
...
@@ -43,6 +43,9 @@ cdef int[:, ::view.contiguous, ::view.indirect_contiguous] a6
...
@@ -43,6 +43,9 @@ cdef int[:, ::view.contiguous, ::view.indirect_contiguous] a6
ctypedef
int
*
intp
ctypedef
int
*
intp
cdef
intp
[:,
:]
myarray
cdef
intp
[:,
:]
myarray
cdef
int
[:]
a10
=
<
int
[:
10
]
>
object
()
cdef
int
[:]
a11
=
<
int
[:
5.4
]
>
<
int
*>
1
# These are VALID
# These are VALID
cdef
int
[::
view
.
indirect_contiguous
,
::
view
.
contiguous
]
a9
cdef
int
[::
view
.
indirect_contiguous
,
::
view
.
contiguous
]
a9
...
@@ -65,4 +68,6 @@ _ERRORS = u'''
...
@@ -65,4 +68,6 @@ _ERRORS = u'''
37:9: Only one direct contiguous axis may be specified.
37:9: Only one direct contiguous axis may be specified.
38:9:Only dimensions 3 and 2 may be contiguous and direct
38:9:Only dimensions 3 and 2 may be contiguous and direct
44:10: Invalid base type for memoryview slice: intp
44:10: Invalid base type for memoryview slice: intp
46:35: Can only create cython.array from pointer or array
47:24: Cannot assign type 'double' to 'Py_ssize_t'
'''
'''
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