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