Commit d467658e authored by Mark Florisson's avatar Mark Florisson

Disallow memoryview struct dtypes with unsupported field types

parent 51a23fd1
...@@ -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))
......
...@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment