summaryrefslogtreecommitdiff
path: root/Cython/Compiler/MemoryView.py
diff options
context:
space:
mode:
authorMark Florisson <markflorisson88@gmail.com>2011-12-04 14:00:11 +0000
committerMark Florisson <markflorisson88@gmail.com>2011-12-04 19:10:38 +0000
commitd467658e69d1eb52f35c2484a009328d132872c4 (patch)
tree2e0aa816c0ac23844171837516b0223461f60836 /Cython/Compiler/MemoryView.py
parent51a23fd162a46e443b628729838e49ce57ba0453 (diff)
downloadcython-d467658e69d1eb52f35c2484a009328d132872c4.tar.gz
Disallow memoryview struct dtypes with unsupported field types
Diffstat (limited to 'Cython/Compiler/MemoryView.py')
-rw-r--r--Cython/Compiler/MemoryView.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Cython/Compiler/MemoryView.py b/Cython/Compiler/MemoryView.py
index 9c94abca8..249195707 100644
--- a/Cython/Compiler/MemoryView.py
+++ b/Cython/Compiler/MemoryView.py
@@ -160,17 +160,25 @@ def src_conforms_to_dst(src, dst):
def valid_memslice_dtype(dtype):
"""
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:
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 (
dtype.is_error or
# Pointers are not valid (yet)
# (dtype.is_ptr and valid_memslice_dtype(dtype.base_type)) or
dtype.is_numeric or
- dtype.is_struct or
dtype.is_pyobject or
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))