diff options
author | Mark Florisson <markflorisson88@gmail.com> | 2011-12-04 14:00:11 +0000 |
---|---|---|
committer | Mark Florisson <markflorisson88@gmail.com> | 2011-12-04 19:10:38 +0000 |
commit | d467658e69d1eb52f35c2484a009328d132872c4 (patch) | |
tree | 2e0aa816c0ac23844171837516b0223461f60836 /Cython/Compiler/MemoryView.py | |
parent | 51a23fd162a46e443b628729838e49ce57ba0453 (diff) | |
download | cython-d467658e69d1eb52f35c2484a009328d132872c4.tar.gz |
Disallow memoryview struct dtypes with unsupported field types
Diffstat (limited to 'Cython/Compiler/MemoryView.py')
-rw-r--r-- | Cython/Compiler/MemoryView.py | 12 |
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)) |