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
d467658e
Commit
d467658e
authored
Dec 04, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disallow memoryview struct dtypes with unsupported field types
parent
51a23fd1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
Cython/Compiler/MemoryView.py
Cython/Compiler/MemoryView.py
+10
-2
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+2
-0
No files found.
Cython/Compiler/MemoryView.py
View file @
d467658e
...
@@ -160,17 +160,25 @@ def src_conforms_to_dst(src, dst):
...
@@ -160,17 +160,25 @@ def src_conforms_to_dst(src, dst):
def
valid_memslice_dtype
(
dtype
):
def
valid_memslice_dtype
(
dtype
):
"""
"""
Return whether type dtype can be used as the base type of a
Return whether type dtype can be used as the base type of a
memoryview slice
memoryview slice.
We support structs, numeric types and objects
"""
"""
if
dtype
.
is_complex
and
dtype
.
real_type
.
is_int
:
if
dtype
.
is_complex
and
dtype
.
real_type
.
is_int
:
return
False
return
False
if
dtype
.
is_struct
and
dtype
.
kind
==
'struct'
:
for
member
in
dtype
.
scope
.
var_entries
:
if
not
valid_memslice_dtype
(
member
.
type
):
return
False
return
True
return
(
return
(
dtype
.
is_error
or
dtype
.
is_error
or
# Pointers are not valid (yet)
# Pointers are not valid (yet)
# (dtype.is_ptr and valid_memslice_dtype(dtype.base_type)) or
# (dtype.is_ptr and valid_memslice_dtype(dtype.base_type)) or
dtype
.
is_numeric
or
dtype
.
is_numeric
or
dtype
.
is_struct
or
dtype
.
is_pyobject
or
dtype
.
is_pyobject
or
dtype
.
is_fused
or
# accept this as it will be replaced by specializations later
dtype
.
is_fused
or
# accept this as it will be replaced by specializations later
(
dtype
.
is_typedef
and
valid_memslice_dtype
(
dtype
.
typedef_base_type
))
(
dtype
.
is_typedef
and
valid_memslice_dtype
(
dtype
.
typedef_base_type
))
...
...
Cython/Compiler/PyrexTypes.py
View file @
d467658e
...
@@ -3068,6 +3068,8 @@ class CUTF8CharArrayType(CStringType, CArrayType):
...
@@ -3068,6 +3068,8 @@ class CUTF8CharArrayType(CStringType, CArrayType):
class
CCharArrayType
(
CStringType
,
CArrayType
):
class
CCharArrayType
(
CStringType
,
CArrayType
):
# C 'char []' type.
# C 'char []' type.
from_py_function
=
None
def
__init__
(
self
,
size
):
def
__init__
(
self
,
size
):
CArrayType
.
__init__
(
self
,
c_char_type
,
size
)
CArrayType
.
__init__
(
self
,
c_char_type
,
size
)
...
...
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