Commit 0961b9a7 authored by Stefan Behnel's avatar Stefan Behnel

Disallow memory views as struct members since structs do not allow safe buffer...

Disallow memory views as struct members since structs do not allow safe buffer reference management.
parent aff88c52
......@@ -9170,6 +9170,7 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin):
if not arg.default.is_literal:
arg.is_dynamic = True
if arg.type.is_pyobject:
# FIXME: should we include memory views here?
nonliteral_objects.append(arg)
else:
nonliteral_other.append(arg)
......
......@@ -1874,11 +1874,12 @@ class StructOrUnionScope(Scope):
entry.is_variable = 1
self.var_entries.append(entry)
if type.is_pyobject and not allow_pyobject:
error(pos,
"C struct/union member cannot be a Python object")
error(pos, "C struct/union member cannot be a Python object")
elif type.is_memoryviewslice and not allow_pyobject:
# Memory views wrap their buffer owner as a Python object.
error(pos, "C struct/union member cannot be a memory view")
if visibility != 'private':
error(pos,
"C struct/union member cannot be declared %s" % visibility)
error(pos, "C struct/union member cannot be declared %s" % visibility)
return entry
def declare_cfunction(self, name, type, pos,
......
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